- SELECT * FROM `table` WHERE FIND_IN_SET( '1', field)
例子
- DROP TABLE IF EXISTS `tests`;
- CREATE TABLE `tests` (
- `int` int(14) NOT NULL AUTO_INCREMENT,
- `value` varchar(255) DEFAULT NULL,
- PRIMARY KEY (`int`)
- ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
- /*Data for the table `tests` */
- insert into `tests`(`int`,`value`) values (1,'4,5,6');
- SELECT * FROM tests WHERE FIND_IN_SET( '4', `value`)
转载请注明:谷谷点程序 » mysql对字段存的以逗号分开的数据查询的方法