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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How do I create this view

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.stuff
from employee e
left join dependants d
on e.employee_id=d.employee_id


www.elsasoft.org
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-05 : 00:22:57
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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.
Go to Top of Page

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 Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

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.
Go to Top of Page

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.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -