I have tables as below
table A
emp_code | emp_name
table B
emp_code | id
table C
emp_code | id
I want to get emp_name so I do:
SELECT a.emp_name
FROM A a, B a
WHERE a.emp_code = b.emp_code
Now I want to capture a case when id in table B is not null and greater than 0 then it should compare a.emp_code with emp_code from table C (like SELECT c.emp_code FROM C c, B b WHERE c.id = b.id) otherwise do as above.