如何实现like in结合,类似regexp_like
SELECT * FROM table where id包含(65,66,67)其中一个的所有数据
id里面的数据,有可能是65,66,67单独的数,也可能是(2,66)和(1,67)这样的值
该怎么写sql语句呢
查了一下oracle里面有regexp_like这种,不知道mysql里面怎么用呢,有米有高手可以帮一下
-
SQL code
mysql> select * from test; +------+ | id | +------+ | 65 | | 1 | +------+ 2 rows in set (0.00 sec) mysql> select * from test where id in(1,65); +------+ | id | +------+ | 65 | | 1 | +------+ 2 rows in set (0.00 sec) mysql> show create table test; +-------+---------------------------------- -----------------+ | Table | Create Table | +-------+---------------------------------- -----------------+ | test | CREATE TABLE `test` ( `id` int(11) default NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | +-------+---------------------------------- -----------------+ 1 row in set (0.00 sec)
SELECT * FROM table where id REGEXP '65|66|67'
如果不是准确匹配