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 |
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2011-11-17 : 14:44:52
|
| hi,I have two tables as follows. Table Name : Users user_id firstName lastName email address representative 1 ross taylor rts@gmail.com hhmc 2 not Assigned pbc@yahoo.com icmcTable Name : Request RequestId representative1 representative21 hhmc icmcmy codiiton here is if firstname+lastName ="NotAssigned" then choose emailaddress belongs to hhmc else choose emailaddress belongs to icmc.by joiing both the query my out put will be as follows by putting requset_id as a input parameter from front end.1 hhmc icmc rts@gmail.compurposely i want to do this using sql query. i know that using stored proc it is vry simple. is ther any way of doing this by sql query |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-11-17 : 15:05:39
|
| Something likeSELECT u.userid,u.firstName,u.lastname,[email] = case when u.firstName+u.lastname = 'NotAssigned' then r.hhmc else r.icmc endFROMUsers U INNER JOINRequest r on u.user_id = r.requestid (i'm not sure how these tables actually join)JimEveryday I learn something that somebody else already knew |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2011-11-17 : 15:25:33
|
| thanks jim i got few idea from your answer |
 |
|
|
|
|
|