in where condition emplyee details is exist in a table eg:table1 then take data from table1 .employee data not exists then take data from another table eg:table2 .
How to do this in where condition
in where condition emplyee details is exist in a table eg:table1 then take data from table1 .employee data not exists then take data from another table eg:table2 .
How to do this in where condition
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajeev KumarPosted Mar 2, 2023, 1:43 PM
Hi you use with EXISTS
IF Exists (select count(1) from table1)
begin
select * from table1 end else
begin select * from table2 end
Naimish MakwanaPosted Feb 10, 2023, 4:44 AM
You can use below query for the same.
Thanks
Jignesh KumarPosted Feb 10, 2023, 4:30 AM
Hello Lejo,
You can use except to achieve your requirement,
Aradhana TripathiPosted Feb 9, 2023, 5:26 PM
You can do this simply using SQL left join clause.
Aravind GovindarajPosted Nov 26, 2022, 11:39 PM
In this case, you can approach if exists a statement or else creates a view internally to apply the union to all required tables. just get it from there....
Sachin SinghPosted Nov 26, 2022, 1:26 PM