Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi ,i have two tables.dept and employee,Below I have shown the structure .here Did is primary key of dept table and Foreign key of employee table.


dept
Did Dname Dnumber
1 d1 23
2 d2 34
3 d4 67


employee
Eid Ename Did
1 e1 1
2 e2 2
3 e3 2

here ,I have to select Ename with respect to Dname..please someone help me..


thank you in advance
Posted

Sounds very much like homework... The thing you need is a join. I suggest going through this tutorial: SQL Joins[^]
 
Share this answer
 
Comments
chinta123 12-May-12 7:09am    
can u please write the query here?
Wendelius 12-May-12 7:23am    
It's important that you try to do the homework yourself. The only way to learn is by trying. And when you try I'm certain that you find, it's not so hard after all :)

If you write the query and encounter a problem, you can post the query you have written with the description of the problem and I'm sure that you'll get help to solve the specific issue.

I'm sure that you if you go through the tutorial and try to write the query, you actually solve it in no time :)
Maciej Los 12-May-12 8:57am    
Good answer! +5
Wendelius 12-May-12 12:39pm    
Thanks
If Did is a PK in dept table and FK in employee table, INNER clause should looks like:
SQL
FROM dept LEFT JOIN employee ON dept.Did = employee.Did

It mean: fetch all data from dept table and metches records from employee table
The rest of query try to write yourself.
 
Share this answer
 
v2
Comments
chinta123 13-May-12 0:57am    
I also that much..can u pls tell me next??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900