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
 search query multiple tables

Author  Topic 

kerwinduke
Starting Member

1 Post

Posted - 2009-06-06 : 20:24:50
having problems designing a query that pulls result set from any of four (4) tables in db.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-07 : 02:56:56
If in understand you correctly, you can join queries from 4 tables using union all and then apply filter. some thing like,

SELECT fields...
FROM
(SELECT field1,filed2,field3,filed4,... FROM table1
UNION ALL
SELECT field1,filed2,field3,filed4,... FROM table2
UNION ALL
SELECT field1,filed2,field3,filed4,... FROM table3
UNION ALL
SELECT field1,filed2,field3,filed4,... FROM table4
)t
WHERE field4=@Yourparameter or search string
Go to Top of Page
   

- Advertisement -