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 |
Anjani
Starting Member
2 Posts |
Posted - 2009-05-28 : 05:47:31
|
Hi, I like to write the query which joins the two tables. I am having two tables named Employee and Dependents. In employee table having columns empid,empname. In Dependents table having columns empid,name,email_id,phonenum. I want to the join the tables and in my final table i want all the columns from both the tables.plz help me in writing the query....Thanks in advance Anjani |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-28 : 06:04:38
|
[code]select *from employee e inner join dependents don e.empid = d.empid[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-30 : 08:41:26
|
If you want to show all records even if there is no matching record in dependents:select *from employee e left join dependents don e.empid = d.empid No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-30 : 08:47:57
|
Although you want all the columns from both the tables, dont use *. Instead explicitely name the columns with prefixing the table aliasesMadhivananFailing to plan is Planning to fail |
|
|
|
|
|