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 |
adam_hh
Starting Member
6 Posts |
Posted - 2007-04-04 : 16:28:06
|
I have two tables employees and dependants. I want to create a view that will list the employee info and thier associated dependant info. I also want employees to be listed if they dont have dependants. The common link is employee_id. I appreciate your help.Thanks. |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-04-04 : 16:31:04
|
select e.employee_id, e.stuff, d.stufffrom employee eleft join dependants d on e.employee_id=d.employee_id www.elsasoft.org |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
adam_hh
Starting Member
6 Posts |
Posted - 2007-04-05 : 08:54:14
|
I written alot of SQL, I don't need a training class, but thanks anyways. As for the code jezemine attached, that's a no go because I need to grab the record from the employee file also. This code will only retrieve the dependant info and not the employee to. I'm going to have to use a tmp table or a static table and reload it everytime I need this data. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-05 : 08:58:14
|
quote: Originally posted by adam_hh I written alot of SQL, I don't need a training class, but thanks anyways. As for the code jezemine attached, that's a no go because I need to grab the record from the employee file also. This code will only retrieve the dependant info and not the employee to. I'm going to have to use a tmp table or a static table and reload it everytime I need this data.
I don't think so! Besides, you have given us really limited info. If you want accurate answers, post more details. We don't have mind-readers attached on our PC !Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
adam_hh
Starting Member
6 Posts |
Posted - 2007-04-05 : 19:35:30
|
Will post more details next time. I ended up creating a temp table to resolve my issue. Thanks for the help. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-04-06 : 12:29:20
|
No offense, but if you used a temp table, then chances are you could use some training in SQL... I suspect that you have really overcomplicated things since temp tables are rarely required and usually end up adding more complexity and inefficiency to your code. Next time, please just give us some more specific information about what you are after and we'll be able to help you.- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
|
|
|
|
|