Home » SQL & PL/SQL » SQL & PL/SQL » Help on select needed
Help on select needed [message #36272] Wed, 14 November 2001 05:36 Go to next message
marco
Messages: 46
Registered: March 2001
Member
Hi,

is it possible to have a single SQL-statement, given the two tables below,that produces the following results?

Select a.Course, a.Teacher, b.Telephone from Table_A a, Table_B b
where (?)

RESULTS:
---------------------------
Course, Teacher, Telephone
1, John,
2, Lisa, 123
3, Ester, 456
---------------------------

Table_A:
Course, Teacher, Book

1, John, A
2, Lisa, B
3, Ester, C
----------------------
Table B:
Teacher, Telephone

Lisa, 123
Ester, 456
-----------------------

If it's not possible, please tell me. Thanks Marco

----------------------------------------------------------------------
Re: Help on select needed [message #36275 is a reply to message #36272] Wed, 14 November 2001 06:43 Go to previous messageGo to next message
Rob Baillie
Messages: 33
Registered: November 2001
Member
Forgive me if I'm being patronising here... but this sounds like a fairly simple equi-join.

What you're looking for is:

SELECT a.Course
, a.Teacher
, b.Telephone
FROM Table_A a
, Table_B b
WHERE a.Teacher = b.Teacher;

For the fundamentals of SQL in Oracle 8, try:

http://otn.oracle.com/doc/server.804/a58225/ch2.htm

Although, if you're not familiar with relational databases this is probably not a good place to introduce yourself to it. If that is the case I would strongly suggest you get a good book on the fundamentals of Relational Database Management Systems.

Hope this is of help to you

Rob

----------------------------------------------------------------------
Re: Help on select needed [message #36279 is a reply to message #36275] Wed, 14 November 2001 07:19 Go to previous messageGo to next message
marco
Messages: 46
Registered: March 2001
Member
Hi Rob,
thanks for your reply, but your select won't produce the results I'm looking for, in fact I would only get records maching by Teacher. Please refer again to my previous post. Marco

----------------------------------------------------------------------
Re: Help on select needed [message #36281 is a reply to message #36275] Wed, 14 November 2001 07:29 Go to previous message
Rob Baillie
Messages: 33
Registered: November 2001
Member
Apologies, Hans is right...

Sorry, I didn't notice that extra line in the required result set.

Will this board ever forgive me?

----------------------------------------------------------------------
Previous Topic: Re: Help Convert VARCHAR2 to number
Next Topic: HELP! SQL*Plus and report formatting/scripting
Goto Forum:
  


Current Time: Thu Mar 28 20:24:12 CDT 2024