Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to query for multiple value combinations in a single table

3627690Jan 27 2018 — edited Jan 27 2018

Hello All,

My apologies if this question has already been answered elsewhere, I did try searching for it, but perhaps did not use the correct search term. Here is my dilemma.

I have a table that contains multiple columns, and I need to select rows based on a combination of values, for example, my table looks like

NAME
FOODDAY
JohnBurgerSunday
JaneBurgerMonday
JohnPizzaSunday
JohnPastaSunday
JohnBurgerTuesday
JaneBurgerTuesday
JanePastaWednesday

So if I want information on which Sunday's john ate burgers for, and which Wednesday's Jane had pasta on.

My query would have to look like

select DAY, NAME, FOOD from FOOD_TABLE FT

WHERE

(DAY='Sunday' and NAME='John')

OR

(DAY='Wednesday' and NAME='Jane')

While it is possible for a table of 6 rows with 2 persons, it would become cumbersome as the conditions increase.

So, my question is, is there a simpler way to do what I am trying?

This post has been answered by Frank Kulash on Jan 27 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2018
Added on Jan 27 2018
4 comments
5,238 views