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 |
|
suguna
Starting Member
6 Posts |
Posted - 2009-07-25 : 02:43:36
|
| Hi allI need a simple query,that to retrive the email from two table,if my email is existing in either one of the table.it should check in both the table,for eg:Table1:name emailnirmala nirmala@gmail.comsuguan suguna@gmail.comTable:2name emaildhina dhina@gmail.comsambath sambath@gmail.comI need asselect * from table1 ,table2 where email='nirmala@gmail.com'If any one knows,Please HelpThanks in advanceSuguna ss |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-07-25 : 03:02:12
|
| Here the Queryselect case when t1. email is null then t2. email else t1. email end as namefrom temp1 t1 left outer join temp2 t2on t1.name=t2.namewhere t1.name = 'aaaa'Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-07-25 : 03:05:38
|
| If your where clause is email then you use this simple oneselect email from temp1 where email='nirmala@gmail.com' union select email from temp2 where email='nirmala@gmail.com'Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
suguna
Starting Member
6 Posts |
Posted - 2009-07-25 : 03:10:14
|
| Thank you Senthil,But i didnt get the query,since I didnt have common field for both the table,thats the difficultPlease Help |
 |
|
|
suguna
Starting Member
6 Posts |
Posted - 2009-07-25 : 03:12:59
|
| Thanks you very muchIts workedThank youSuguna |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-07-25 : 03:15:05
|
quote: Originally posted by suguna Thanks you very muchIts workedThank youSuguna
Ya welcome. Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
|
|
|