Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Query Help
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
![]() |
![]() |