Click here to Skip to main content
15,078,444 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have 3 tables in my database and i have a column news varchar(max) in all 3 tables and i want to search a given text in all the tables and want to know in which table that text is present.what will be the query?
Posted
Updated 27-Oct-13 20:48pm
v2
Comments
TrushnaK 28-Oct-13 2:56am
   
what you have tried so far....
post you tried query and table stucture.

You can use full text search for each table:
SELECT id,news FROM products WHERE CONTAINS(news, "words to search here")

Please refer the link : SQL Full Text Search Programming[^]
   
v2
lets say there are 3 tables employee,student,employer and all three has a Address column
use this query to see in which table the text is available.

SQL
SELECT		a.Address as employeeAddress,
			b.Address as studentaddress,
			c.Address as employeraddress
FROM		employee	a left outer join
			student		b
			on a.empcode = b.stid
			left outer join
			employer	c
			on b.stid = c.EmployerCode			
where		(
			a.Address	like '%texttobesearched%'
			OR
			b.Address	like '%texttobesearched%'
			OR
			c.Address	LIKE '%texttobesearched%'
			)


Hope this helps!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900