Home » SQL & PL/SQL » SQL & PL/SQL » SQL Query help
SQL Query help [message #348067] Mon, 15 September 2008 09:26 Go to next message
MicheChekra
Messages: 2
Registered: September 2008
Junior Member
Hi All, i am new to sql and i hope you can help solve this problem.
i have 2 tables,( foods, and subject_foods) the first one has a column called (name) which contains food names such as

AMERICAN CHEESE FOOD - Borden
AMERICAN CHEESE SPREAD - Sargento
ANGEL FOOD CAKE MIX
ANIMAL CRACKER, ERNIE'S - Keebler
...

another table has a column Food_Name:
cheese
cake
...

i want to return from the first table all the records that contains a word of the second table
I used:

SELECT name FROM foods, subject_foods WHERE lower(Name) || UPPER(NAME) LIKE subject_foods.food_name;

but this only return if there is an exact match, it doesn't return all the records that contains the words cheese or cake.

thank you.
Re: SQL Query help [message #348068 is a reply to message #348067] Mon, 15 September 2008 09:28 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I'd use the INSTR command if I were you:
WHERE INSTR(lower(name),lower(food_name)) > 0
Previous Topic: pointers
Next Topic: How to generate random positive numbers?
Goto Forum:
  


Current Time: Wed Dec 07 10:59:27 CST 2016

Total time taken to generate the page: 0.11126 seconds