I have mysql table values like
1-2
1-2-3
1-4-5
1-4-5-12-15
15-45-75
1-5-15-25-35-55
55-65-75
I want to select which rows have number 5(not 15 or 25 or 35).
I have tried with LIKE query but it gives all 5 value contains rows(including 15, 35, 45,55).
SELECT ... WHERE linkage LIKE '%5%'
I think we can do it through REGEXP. Can you help me for it?
You can do this using FIND_IN_SET:
SELECT ...
WHERE FIND_IN_SET(5, REPLACE(linkage,'-',','));
try
SELECT ... WHERE concat('-',linkage,'-') LIKE '%-5-%'
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