Select from 3 tables [message #382158] |
Wed, 21 January 2009 03:39 |
naps
Messages: 4 Registered: January 2009
|
Junior Member |
|
|
Hello how can i select from 3 tables?
I have tables
Employee :
Id Name Salary
Technician :
Speciality PreviousExpirience employee.ID
Salesman :
Degree University Date employee.ID
I want to select employee for a specific id but i don't know how to combine them?
|
|
|
|
|
|
|
|
|
|
Re: Select from 3 tables [message #382286 is a reply to message #382275] |
Wed, 21 January 2009 14:47 |
|
Littlefoot
Messages: 21821 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
naps | I want to select employee for a specific id
| This one is quite simple:select *
from employee
where id = specific_id;
If this "employee" is a technician, join these two tables by a common column - I'd say it is the ID:
select e.id, e.name, e.salary,
t.speciality, t.previousexpirience
from employee e,
technician t
where e.id = t.id;
The "salesman" table can be added into that query using the same principle. I believe you should be able to do it yourself. If not, well, provide what you've managed to write. Someone will certainly take a look and suggest what can be done in order to make it work.
Anyway, I'd strongly suggest you to read a document Michel provided, search for more "join" examples, practice and simple queries as this one shouldn't be a problem any more.
|
|
|