Home » SQL & PL/SQL » SQL & PL/SQL » Select from 3 tables
Select from 3 tables [message #382158] Wed, 21 January 2009 03:39 Go to next message
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 #382162 is a reply to message #382158] Wed, 21 January 2009 03:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use JOINS.

Regards
Michel
Re: Select from 3 tables [message #382254 is a reply to message #382158] Wed, 21 January 2009 09:38 Go to previous messageGo to next message
naps
Messages: 4
Registered: January 2009
Junior Member
trying to do it but i can't.

Any help?
Re: Select from 3 tables [message #382255 is a reply to message #382158] Wed, 21 January 2009 09:43 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
So we can help you & please be consistent & correct in your postings.

Post DDL for tables.
Post DML for test data.

Post expected/desired results.
Re: Select from 3 tables [message #382261 is a reply to message #382254] Wed, 21 January 2009 10:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Post what you tried.

Regards
Michel
Re: Select from 3 tables [message #382270 is a reply to message #382158] Wed, 21 January 2009 11:09 Go to previous messageGo to next message
naps
Messages: 4
Registered: January 2009
Junior Member
I just want to check in which table exists a specific employee.Id

but i don't know hot to do it!
Re: Select from 3 tables [message #382273 is a reply to message #382158] Wed, 21 January 2009 11:31 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
SELECT ...... FROM .... WHERE .....
Re: Select from 3 tables [message #382275 is a reply to message #382270] Wed, 21 January 2009 11:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It's time to read a SQL tutorial or take a course.
You can't get help from a forum if you don't know the basic.

Regards
Michel
Re: Select from 3 tables [message #382286 is a reply to message #382275] Wed, 21 January 2009 14:47 Go to previous message
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.
Previous Topic: Inheritance and Collections
Next Topic: Create table with email body
Goto Forum:
  


Current Time: Mon Nov 04 05:30:57 CST 2024