表是
CREATE TABLE `news` (
`id` bigint(20) NOT NULL auto_increment,
`title` varchar(255) default NULL,
`tagkey` text NOT NULL,
PRIMARY KEY (`id`)
) ;
INSERT INTO `news` VALUES (1, 'TITLE1','3D');
INSERT INTO `news` VALUES (2, 'TITLE2 ','cat');
INSERT INTO `news` VALUES (3, 'TITLE2','BOOKs,3D');
INSERT INTO `news` VALUES (4, 'TITLE1','3D,DOG');
INSERT INTO `news` VALUES (5, 'TITLE2 ','DOG');
INSERT INTO `news` VALUES (6, 'TITLE2','BOOKs,DOG');
INSERT INTO `news` VALUES (7, 'TITLE1','Wolf,DOG');
INSERT INTO `news` VALUES (8, 'TITLE2 ','cat,DOG');
INSERT INTO `news` VALUES (9, 'TITLE2','BOOKs,cat');
如何查询'猫',书。使用了这个查询。但无法搜索正确的数据。
select * FROM news WHERE tagkey IN ('book','cat')
$list = array('cat','DOG');
$list = array_map('apply_quotes', $list);
$query = "select * FROM news
WHERE tagkey IN (" . join(',', $list) . ") AND id <> $id";