Reputation: 89
I have a particular condition in oracle which I am trying to run in MS SQL Server, but having issues..
Here is the code...
select a.*,b.*
from a
left join b on a.id = b.id
and (a.id,b.name) in
( select distinct id,name
from master where record = 'Active')
I am getting the error in line 3 where it says:
An expression of non-boolean type specified in a context where a condition is expected, near ','.
Pls help
Upvotes: 0
Views: 102
Reputation:
You need to rewrite that into an EXISTS
condition:
select a.*,b.*
from a
left join b on a.id = b.id
and exists (select *
from master m
where m.record = 'Active'
and m.id = a.id
and m.name = b.name)
Upvotes: 2
Reputation: 6088
You can't write like this (a.id,b.name)
select a.*,b.*
from a
left join b on a.id = b.id
and a.id in
( select distinct id
from master where record = 'Active')
and b.name in ( select distinct name
from master where record = 'Active')
Upvotes: 0