Zecrow
Zecrow

Reputation: 233

Mysql Like from imploded by commas field

if i write:

SELECT * FROM users WHERE themes LIKE '%3%'

from the field themes = '1, 2, 3, 4, 5', how to write right '%3' or '3%' or '%3%'

just to check if the user has selected one of those themes

Upvotes: 0

Views: 44

Answers (1)

John Woo
John Woo

Reputation: 263693

use FIND_IN_SET

SELECT * 
FROM users 
WHERE FIND_IN_SET(3, themes) <> 0

Upvotes: 1

Related Questions