- SELECT * FROM tests WHERE IF(STATUS=1,FIND_IN_SET(4,VALUE),STATUS)
- //例子
- DROP TABLE IF EXISTS `tests`;
- CREATE TABLE `tests` (
- `int` int(14) NOT NULL AUTO_INCREMENT,
- `value` varchar(255) DEFAULT NULL,
- `status` int(1) DEFAULT '0',
- PRIMARY KEY (`int`)
- ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
- /*Data for the table `tests` */
- insert into `tests`(`int`,`value`,`status`) values (1,'4,5,6',0),(2,'4,5,7,8',1);
转载请注明:谷谷点程序 » mysql where if的例子