dbTalk Databases Forums  

Inner join with where

comp.databases.oracle comp.databases.oracle


Discuss Inner join with where in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Nerfherder
 
Posts: n/a

Default Inner join with where - 02-06-2005 , 07:20 PM






I have the following SQL statement I need to
add a secondary where clause to

SELECT name, amount
FROM node, log
WHERE log.name (+) = node.name

Now I need to add run_date = '31-JAN-05',
I can not just add this statement since when I do
loose columns in the node table since there is
not a 1:1 match between the two tables.

--

Reply With Quote
  #2  
Old   
Mark C. Stock
 
Posts: n/a

Default Re: Inner join with where - 02-06-2005 , 07:52 PM







"Nerfherder" <nobody (AT) home (DOT) com> wrote

Quote:
I have the following SQL statement I need to
add a secondary where clause to

SELECT name, amount
FROM node, log
WHERE log.name (+) = node.name

Now I need to add run_date = '31-JAN-05',
I can not just add this statement since when I do
loose columns in the node table since there is
not a 1:1 match between the two tables.


which table is the run_date column in?

bottom line, you have to include the oracle's outer join syntax in all
affected predicates, so, depending on which table RUN_DATE is in, you need
to add either

run_date = to_date('31-JAN-05','dd-mon-rr') (+)

or

run_date(+) = to_date('31-JAN-05','dd-mon-rr')


note also that you should never use implicite date conversion -- either use
TO_CHAR or the ansi date literal syntax (if using 10g)

++ mcs




Reply With Quote
  #3  
Old   
Nerfherder
 
Posts: n/a

Default Re: Inner join with where - 02-07-2005 , 04:09 PM



"Mark C. Stock" <mcstockX@Xenquery .com> said:

Thanks, that worked.

Quote:
to_date('31-JAN-05','dd-mon-rr')


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.