Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
callinnn
Starting Member
7 Posts |
Posted - 2007-06-25 : 07:42:52
|
| Hi all,select u_emp,(select name from [@emp] where code=u_emp) name1from ovpm This query gives me the output having employee code and name.I want to further filter the employee name by giving a where clause as where name1='Carell'Is it possible?Please Help |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-25 : 07:55:27
|
Yes and I would rather prefer JOIN over Subquery:select o.u_emp, e.name from ovpm o JOIN [@emp] e on e.code = o.u_empwhere e.name = 'Carell' Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-25 : 08:51:55
|
quote: Originally posted by callinnn Hi all,select u_emp,(select name from [@emp] where code=u_emp) name1from ovpm This query gives me the output having employee code and name.I want to further filter the employee name by giving a where clause as where name1='Carell'Is it possible?Please Help
You should use JOIN as suggested. Otherwise your query will lead to error if subquery returns more than one valueMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|