Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple SQL Query
Muggle wrote:
> Hello everyone,
>
> I have a simple requirement here. Need some help.
>
> I have two tables: TableA and TableB. I want to retrieve all the
> columns from TableA and column EVENT, if there is a record present,
> from TableB. The column that joins the two tables is YEAR.
>
> I am trying to execute a query like this :
>
> Select TableA.*, TableB.EVENT from TableA, TableB where
> TableA.YEAR='1900' and TableA.YEAR= TableB.YEAR
>
> Obviously this returns nothing when TableB has no entry for Year 1900.
> When there is no record present I want the query to return a null for
> the EVENT column and all the columns from TableA.
>
> I have no control over the database design.
>
> Thanks in advance
> Muggle
Investigate outer join syntax. This link includes several examples: http://groups.google.com/group/ORACLE_DBA_EXPERTS/browse_thread/thread/41863b746cbef8d2/ad1c7a3ee4911065?
Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.
Received on Tue Jan 02 2007 - 15:55:09 CST