[广告]: 代充Paypal帐号美元
求一个SQL查询方法
有一数据表:
CREATE TABLE `test` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
`sort` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;
--
-- 导出表中的数据 `test`
--
INSERT INTO `test` (`id`, `name`, `sort`) VALUES (1, 'a', '1,2,3,15,87,9');
INSERT INTO `test` (`id`, `name`, `sort`) VALUES (2, 'b', '1,10,13,5,7,9');
INSERT INTO `test` (`id`, `name`, `sort`) VALUES (3, 'c', '');
INSERT INTO `test` (`id`, `name`, `sort`) VALUES (4, 'd', '1,7,100');
现在想查询sort字段里是否包含了一个或多个符合条件的,如要查询是否包含了"1"和"7",查询要怎么写?谢谢了.
像上例,应该返回的是第2和第4条记录.
[ 本帖最后由 applee 于 2007-9-22 12:00 PM 编辑 ]
|