SQL help, LIKE %(set of possible values)%
April 14, 2010 5:20 PM Subscribe
SQL problem. I need to search one table based on the results of a search on another table.
The trick? The field I'm comparing on the two tables will not be exactly equal, one table will have a field with single 'word', the other table will have a field with have a string of multiple 'words'.
Look inside for an example.
Two tables, FOOD and PEOPLE.
What I want is to return the NAME of all PEOPLE that have a COMMENT that contains a FOOT of TYPE 'fruit'
Table FOOD
FOOD TYPE
apple fruit
banana fruit
carrot vegetable
Table PEOPLE
NAME COMMENT
zackary apples are my favourite food
yvonne monkeys enjoy bananas
xavier melons are delicious
In this example, what I need returned is {zackary, yvonne}
How can I do this without writing multiple individual LIKE statements?
Can I somehow do a LIKE %(set of possible values)% statement?
My actual data has hundreds of rows in the 'FOOD' table.
posted by thisisnotbruce to computers & internet (13 answers total)
posted by miyabo at 5:26 PM on April 14, 2010