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 |
irfi
Starting Member
2 Posts |
Posted - 2012-05-29 : 12:11:31
|
Hi everyone!This is my first post and i would appreciate if someone could help me with the SQL Query to look for records in first table and then if not found look in second table and populate the fields on my windows form. In case records not found in both tables then i will display records not found. "Select a.id, a.name, b.dept from emp_table1 a, dept b where a.id = b.id and a.id=" & Text1.text""Select a.id, a.name, b.dept from emp_table2 a, dept b where a.id = b.id and a.id=" & Text1.text"Thanks and Cheers!IrFi |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-29 : 12:19:41
|
quote: Originally posted by irfi Hi everyone!This is my first post and i would appreciate if someone could help me with the SQL Query to look for records in first table and then if not found look in second table and populate the fields on my windows form. In case records not found in both tables then i will display records not found. "Select a.id, a.name, b.dept from emp_table1 a, dept b where a.id = b.id and a.id=" & Text1.text""Select a.id, a.name, b.dept from emp_table2 a, dept b where a.id = b.id and a.id=" & Text1.text"Thanks and Cheers!IrFi
"SELECT a.id, a.name, b.dept FROM (SELECT id, name from emp_table1 union Select id, name from emp_table2 )adept b where a.id = b.id and a.id=" & Text1.text" ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
irfi
Starting Member
2 Posts |
Posted - 2012-05-31 : 05:35:53
|
Thanks a lot visakh16 for your reply. It worked like a charm.regards,Irfi |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-31 : 16:09:05
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|