Search three fields for same criteria

  • Thread starter Thread starter Amelia
  • Start date Start date
A

Amelia

MON | TUE | WED
-----------------------------------
Mary Apples | Apples | Berries
Tom Berries | Berries | Plums
Sally Apples | Berries | Apples

Question: Who has sold Apples?

right now i've got:

SELECT *
FROM Table
WHERE (
(MON) Like [Enter Fruit]
Or (TUE) Like [Enter the same Fruit again]
Or (WED) Like [Enter the same Fruit once more]
);

There's got to be a simpler way.

Thanks in advance,
amelia
 
I expect your sample is just a simplification. However, your table is not
normalized since date values should be values and not field names. However,
that said, you should be able to use:

SELECT *
FROM Table
WHERE (
(MON) Like [Enter Fruit] & "*"
Or (TUE) Like [Enter Fruit] & "*"
Or (WED) Like [Enter Fruit] & "*"
);

I'm not sure why you used "Like" without a wildcard character...
 
I know this is an exercise, but why not just change the table design?
Salesperson
DayofWeek
Fruit

Then you can query on the one parameter [?], and return all who sold the
fruit on each day. Probably a lesson to all on proper table design. (Not
that mine is the best way to go)

HTH
Damon
 
Maybe select * from tablename where (field1 = field2) and (field 2 = field 3)

That might only pull records where all three fields are the same.


(e-mail address removed)
 
Back
Top