I've got a mysql table with the following data:
ID | Name
1 | xy
4 | dasd
9 | 422p
10 | dasös
and I've got the following query which should display only the values "1 and 4", but it displays 1,4,10.
rlike '1|^4'
any idea?
I've got a mysql table with the following data:
ID | Name
1 | xy
4 | dasd
9 | 422p
10 | dasös
and I've got the following query which should display only the values "1 and 4", but it displays 1,4,10.
rlike '1|^4'
any idea?
If you insistence for use RLIKE
, You can use this query:
SELECT * FROM `test` WHERE `id` RLIKE '^1$|^4$';
See online: http://sqlfiddle.com/#!9/c0ede/1/0
But better then and more efficient and more principled and faster then is use IN
, be like this:
SELECT * FROM `test` WHERE `id` IN (1, 4);
See online: http://sqlfiddle.com/#!9/c0ede/2/0
Thanks