Zayo Jozef Zador
Zayo Jozef Zador

Reputation: 1

how can i select mysql row where field contains exact integrer into string?

i have field in mysql row what contains: 5,15,25,30

i need return true for integrer 30, and return false for 3.

what mysql string function is?

when i using LIKE %3% return is true, but mysql field no contain integrer 3 (string yes but integrer no)

thankyou vary much Jozef

Upvotes: 0

Views: 47

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270401

Use find_in_set():

where find_in_set(30, field) > 0

As a note: storing lists of ids in comma-delimited strings is a bad idea. You should be using a junction table instead.

Upvotes: 2

Related Questions