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 |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-06-17 : 19:23:37
|
| select a.emp_id ,a.emp_name,b.phone,b.email,c.dept,c.course,d.address,e.scores,f.hobbiesfrom emp_details a ,contact b,Courses C ,property d,claims e ,personal FNow I have a reference table where I have say 20-25 emp_id which is called emp_tableemp_table:12245634...... which have the emp_idsNow all the tables used in the select statement have an emp_id which can be used to join between tables to pull according to the reference emp_idNow in emp_details emp_id is emp_id contact emp_id is Inc_id property emp_id is Id claims emp_id is C_id personal emp_id is emp_idNow I need to join all of then to get the corressponding records with reference to the emp_id in the emp_table |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-06-17 : 19:28:35
|
| from emp_details a, contact b, Courses C1. Don't do that. It's not correct syntax. --Use FROM emp_details a INNER JOIN contact b ON a.emp_id = b.emp_id etc. etc.2. Look at INNER JOIN and LEFT OUTER JOIN in Books Online. That will give you waht you are looking for. You should really look at SELECT in Books Online and figure out how it works also.Have fun learning.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-06-17 : 19:29:51
|
| from emp_tablejoin emp_detailson emp_table.emp_id = emp_details.emp_idjoin contacton emp_table.emp_id = contact.Inc_idjoin ...==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|