November 7, 2011 at 9:00 am
select *
from
a,b,c
where
A.cash_id in
( select B.cash_id
from B
where B.cash_id = C.cash_id
)
November 7, 2011 at 9:10 am
Why do you want to?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 7, 2011 at 9:14 am
skanth (11/7/2011)
select *
from
a,b,c
where
A.cash_id in
( select B.cash_id
from B
where B.cash_id = C.cash_id
)
Based on your query, all three tables (a,b, & c) link on "cash_id". So, you can just perform an inner join on each of them on this column unless there is something else not depicted in your sample.
select *
from a
join b
on b.cash_id=a.cash_id
join c
on c.cash_id=a.cash_id
November 7, 2011 at 9:23 pm
skanth (11/7/2011)
select *from
a,b,c
where
A.cash_id in
( select B.cash_id
from B
where B.cash_id = C.cash_id
)
The literal translation of that query to join syntax is:
SELECT *
FROM A JOIN C ON C.id = A.id
CROSS JOIN B
WHERE EXISTS (SELECT * FROM B WHERE B.id = C.id)
It's almost certainly not what you intended (particularly the cross join, and referencing table B twice) so the join form of the query as you probably intended it is close to what John gave, depending on how duplicates and NULLs should be handled.
November 7, 2011 at 10:30 pm
the oledb source is not accepting parameters for sql commands with sub queries....... so i need the joins instead of subqueries..!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply