Home » SQL & PL/SQL » SQL & PL/SQL » Without joins
Without joins [message #8228] Tue, 05 August 2003 04:08 Go to next message
capri
Messages: 4
Registered: July 2003
Junior Member
select a.ename,a.sal,a.deptno,b.loc from emp a,dept b
where a.deptno=b.deptno(+);
I have to write a query without using joins how to go abt this thanks is advance
Re: Without joins [message #8233 is a reply to message #8228] Tue, 05 August 2003 06:57 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
quote from capri:
----------------------------------------------------------------------
select a.ename,a.sal,a.deptno,b.loc from emp a,dept b
where a.deptno=b.deptno(+);
I have to write a query without using joins how to go abt this thanks is advance  

----------------------------------------------------------------------
Capri, with all due respect, that is like saying, "I have to drive to work without using wheels how to go abt this thanks in advance".

Joins are not evil! [[T]]he database was built to join, joins are not evil, improperly designed tables (eg: a lookup without an index perhaps) are. Joins are part and parcel of how databases work. If you work with databases but don't use joins, you won't be working with databases for very long.

Just out of curiosity, what is the source of your "requirement" to avoid joins? This class of request ("I want to go swimming, but without getting myself wet") never ceases to puzzle me.

A.
Re: Without joins [message #8236 is a reply to message #8233] Tue, 05 August 2003 08:50 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
Maybe this is a homework assignment where they want you to research natural joins. Now those are evil.

btw
> where a.deptno=b.deptno(+);
Is it just me or is that back to front? I know SQL doesn't care, it makes no difference to the logic, and SQL textbooks tend to write outer joins this way around, but ask yourself would you write

WHERE 'Smith' = ename

or

WHERE ename = 'Smith'

Outer joins are confusing enough without everybody writing them backwards. Stop the madness, write

WHERE b.deptno (+)= a.deptno;
Re: Without joins [message #8238 is a reply to message #8233] Tue, 05 August 2003 10:57 Go to previous messageGo to next message
Meenakshi.
Messages: 4
Registered: July 2003
Junior Member
Hi,

What are "natural joins"? Under what circumstances should subqueries be a choice over joins?

Thanks.
Re: Without joins [message #8247 is a reply to message #8233] Tue, 05 August 2003 23:32 Go to previous message
capri
Messages: 4
Registered: July 2003
Junior Member
Hi A,
You are right,i totally agree with ur view.But it was asked to me in an interview.
Bye
Previous Topic: Loading ASCII or CSV file to table
Next Topic: Inserting Picture
Goto Forum:
  


Current Time: Thu Apr 25 18:48:16 CDT 2024