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
 combine 4 tables and get statuses

Author  Topic 

Maachie
Yak Posting Veteran

69 Posts

Posted - 2008-04-11 : 09:36:37
If i have to get the statuses from four different tables but want to get first table disabled , second table active and also have statuses field from the 3rd and 4th table how would i do that?

ALM,
PV,
AD,
ACE

select * from all tbls
where alm.id = pv.id
and alm status = 'disabled'
and pv status = 'active'

I want to include the status field from 3rd and 4th table.

THanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-11 : 12:02:33
Post your table structures and sample data if you want accurate solution. But something like this should do it for you:-

SELECT otherfields,ALM.status,PV.status,AD.status,ACE.status
FROM ALM
INNER JOIN PV
ON PV.id=ALM.id
INNER JOIN AD
ON AD.id=PV.id
INNER JOIN ACE
ON ACE.id=AD.id
WHERE ALM.status='disabled'
AND PV.status='active'

I'm assuming you have id field in all table.
Go to Top of Page
   

- Advertisement -