I have a table field events which can contains:
45|, for example 55|65|76I think i have to use LIKE, but i don't know how. Can you help me?
Thanks
I would recommend using CONCAT to add a pipe | before and after your field, and then using a LIKE search. Something like this:
SELECT *
FROM YourTable
WHERE concat('|',field,'|') like '%|45|%'
However, I highly recommend trying to normalize your data. Considering storing these in separate rows which would make searching/maintaining much easier.
To fix your query, use:
Select * from tbl where events='45' or events like '%|45' or events like '%|45|%' or
events like '45|%'
but this is terribly slow and should not be used.
Instead, do as Marc B states and create a child table events (ID, event).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With