Multiple LIKE in SQL
Posted
by ninumedia
on Stack Overflow
See other posts from Stack Overflow
or by ninumedia
Published on 2010-05-30T21:14:36Z
Indexed on
2010/05/30
21:22 UTC
Read the original article
Hit count: 252
I wanted to search through multiple rows and obtain the row that contains a particular item.
The table in mySQL is setup so each id has a unique list (comma-delimited) of values per row.
Ex:
id | order
1 | 1,3,8,19,34,2,38
2 | 4,7,2,190,38
Now if I wanted to pull the row that contained just the number 19 how would I go about doing this? The possibilities I could figure in the list with a LIKE condition would be:
19, ,19 ,19,
I tried the following and I cannot obtain any results, Thank you for your help!
SELECT *
FROM categories
WHERE order LIKE '19,%' OR '%,19%' OR '%,19%'
LIMIT 0 , 30
© Stack Overflow or respective owner