I have multiple ID’s in a single field like this
field_name
+----------+
12345|34456|43564
Now what I wanted is to get the row if it matches even a single number perfectly so I searched a little and I found this and used it in my query but it failed
SELECT field_name FROM tbl_name WHERE field_name REGEXP '[[:<:]]34456[[:>:]]';
So I used this a back-slash and it worked,
SELECT field_name FROM tbl_name WHERE field_name REGEXP '[[:<:]]34456\[[:>:]]';
so is it perfect or I am going wrong somewhere? I need an exact match, I don’t want that that am hunting for 34456 and if 34457 is there and it takes that, I want EXACT match, and I can’t use WHERE here
Well, no solution is going to be “perfect” if you store ids like that 🙂
MySQL has a function called
FIND_IN_SETthat can be useful for this type of task, but it assumes your list is comma-delimited. So you’ll need to replace the pipes with commas in order to use that function.Something like this should work: