Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Query Help

Re: Query Help

From: Charles Hooper <hooperc2000_at_yahoo.com>
Date: Fri, 21 Dec 2007 11:06:09 -0800 (PST)
Message-ID: <ca0b7d13-f686-4233-8700-13316c17c3be@e25g2000prg.googlegroups.com>


On Dec 21, 12:48 pm, cnbla..._at_juno.com wrote:
> I am a beginning Oracle 9i user and I was hoping that someone can help
> me.  I think I have the basic SQL statements down pat, but this
> problem is a little too advanced for me.
>
> Let's say that I have Table A with the following columns:  Food_ID,
> Descr, Cat_ID and Status.  Here are some sample rows in the table:
> 301  Apple  10  Active
> 301  Ham  20 Inactive
> 301  Carrot 30 Active
> 302  Orange  10 Inactive
> 302  Balony  20  Active
>
> I would like to find all instances where the Food_ID does not have a
> Cat_ID of 30 or has a Cat_ID of 30, but it is Inactive. In the example
> shown above, I would see Food_ID of 302, but not 301.
>
> Thank you,

If you are famailar with BASIC programming, a similar construct might look like this:
  IF (AGE <> 65) OR (AGE = 65 AND RETIRED = "Y") THEN

The WHERE clause syntax in Oracle is similar to the above, if you omit the "IF" and the "THEN", and replace the double quotes with single quotes. All that you would then need to do is substitute your column names and the values that you are checking.

Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. Received on Fri Dec 21 2007 - 13:06:09 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US