I have tried a lot of syntax but nothing is working. I have MySQL 8.0.31 with phpMyAdmin 5.1.1.
My table looks like this (the column I want to filter by):
The thing is, I'm saving in this field some order numbers, and I need to make a SELECT statement in which I have one order number (for example, 1632) and I need to determine if this number is stored inside the "array" of orders in any of the rows (in this example, the desired result of the query is the third row).
I have tried the IN statement without result. If I use the LIKE statement obviously works, but in case of larger numbers (like 16320), if I'm searching for 1632, I will find also this value.
The separator of the numbers, if works with another one, is able to be changed.
CodePudding user response:
I would do it as such
SELECT * FROM Orders
WHERE Ordernes LIKE '%,$searchValue,%' OR Ordernes
LIKE '$searchValue,%' OR Ordernes LIKE '%,$searchValue';
If you add the seperators on both sides you will only find the value that you are looking for and not numbers that look like it.