Decode in the where clause [message #300565] |
Sat, 16 February 2008 02:03 |
saharookiedba
Messages: 56 Registered: September 2007 Location: PUNE
|
Member |
|
|
Hi,
I am stuck in a query
In the following query
I have a table hardware where i have a field 'predecessor' which is a self link to the Primary key 'ID' of hardware.
Here i display the hardware ID, the ID of the predecessor & the current user.
This returns me nothing if a hardware does not have a predecessor i.e that predecessor
is null.
SELECT hw1.ID, hw1.predecessor, u.Name
FROM hardware hw1, hardware hw2, users u
WHERE hw1.predecessor = hw2.ID
AND hw1.currentuser = u.ID
Can i write a DECODE statement which makes sure that this condition
hw1.predecessor = hw2.ID
is not checked if the hardware does not have predecessor & checks the same when there is a predecessor..
Please help me out in this....
Is there any other way other than decode...
|
|
|
|
Re: Decode in the where clause [message #300577 is a reply to message #300567] |
Sat, 16 February 2008 04:21 |
saharookiedba
Messages: 56 Registered: September 2007 Location: PUNE
|
Member |
|
|
Thanks Michel,
Also Sorry at the same time, for posting the query a the expert forum,
I have used Left Outer join and it has given me the right result.
I'll also go to the ORAFAQ Forum Guide & get back to you,
|
|
|