Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 querying multiple tables based on a condition

Author  Topic 

ashley.s
Starting Member

9 Posts

Posted - 2012-05-27 : 03:13:35
Hello,
I have 3 tables. All three tables have a column called name of person. I need to find details about the name of the person.See syntax below.

select [Cage 1GdB].NameAddofAdd, [Cage 2GdB].NameAddofAdd, [Cage 3GdB].NameAddofAdd from [Cage 1GdB], [Cage 2GdB], [Cage 3GdB] where NameAddofAdd = 'ALISON SONY ROYAL ROAD BELVEDERE, LALLMATIE'

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-27 : 08:25:04
SELECT NameAddOfAdd
FROM (
select NameAddofAdd FROM [Cage 1GdB]
UNION
SELECT NameAddofAdd FROM [Cage 2GdB]
UNION
SELETC NameAddofAdd FROM [Cage 3GdB]
) AS d
WHERE NameAddofAdd = 'ALISON SONY ROYAL ROAD BELVEDERE, LALLMATIE'



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-27 : 11:33:17
quote:
Originally posted by ashley.s

Hello,
I have 3 tables. All three tables have a column called name of person. I need to find details about the name of the person.See syntax below.

select [Cage 1GdB].NameAddofAdd, [Cage 2GdB].NameAddofAdd, [Cage 3GdB].NameAddofAdd from [Cage 1GdB], [Cage 2GdB], [Cage 3GdB] where NameAddofAdd = 'ALISON SONY ROYAL ROAD BELVEDERE, LALLMATIE'


how should be your output? you want them in different columns or inside single column as values?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -