mysql 查询某字段里含有(或者不含)某字符的所有记录方法(转)

select gid, username from users where FIND_IN_SET(8,gid); //查询gid里含有数字8的记录,gid是varchar ,数据格式:"1,12,8,18,5"

 

select gid, username from users where !FIND_IN_SET(8,gid); //查询gid里不含有数字8的记录,gid是varchar ,数据格式:"1,12,8,18,5"

posted @ 2013-07-27 23:16  幻星宇  阅读(3755)  评论(0编辑  收藏  举报