Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi how can i write oracle query when conditon of column satisfies then value should be take from another table


for eg


select ename,enmae,
case when loc='zyz' then
select location pin from pincode where pincodeno='zyz'
end
from emp;

Thanks in advance
Posted
Comments
ZurdoDev 28-Dec-13 11:19am    
Join them first.

1 solution

I think you're looking for EXISTS[^] statement.

SQL
SELECT ename, enmae
FROM emp WHERE EXISTS(SELECT [location pin] FROM pincode WHERE pincodeno='xyz' AND emp.loc=pincode.pincodeno);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900