mysql not in 不生效问题

再一次查询中如下:

SELECT
	`NAME`,
	`CODE`,
	source_code,
	content_tvpe,
	genre,
	description,
	director,
	actor,
	region,
	`LANGUAGE`,
	rating,
	`YEAR`,
	episode_number,
	big_image1,
	date_format( UPDATE, '%Y-%m-%d' ) 
FROM
	epg.tv_program_ext_fdn 
WHERE
	NAME `not LIKE '%预告%'
	and` NAME `not LIKE '%看点%' and ` NAME `not LIKE '%花絮%'
	and` NAME `not LIKE '%独家策划%' 
	AND 'namenot like '%超体%'
	AND ` NAME ` NOT LIKE '%纪实新闻%'
	and name not like '%中超%*' 
	AND content type IN (
	'少儿',体育','娱乐','教育''电影,'生活''电视剧",'动漫',"游戏",'综艺''电竞','纪录片','纪实,
	'戏剧",'有声读物') 
	ands source_code is not NULl 
	and source_code not in ( 
	"HBYD_CP_KDXFYYZQ',
	'HBYD CP HZZYWDJP',
         'HBYD CP CZSP' 
	'HBYD CP HUASHU', 
	'HBYD_CP ZLYP', 
	'HBYD CP HZZY',
	'HBYD_CP_YANHUA',
	'HBYD CP MGTY',
	'HBYD_CP WLDS'
	'HBYD_CP_ZHONGYI',
	'HBYD CP_CDCL',
	'HBYD_CP_MGIC',
	'HBYD_CP_MANGO '. 
	'HBYD_CP_SXFT',
	'HBYD_CP_SHENGJIAN'.
	'HBYD_CP_LEWEI', 
	'HBYD_CP_JUNRONG',
	'HBYD_CP_KDXE",
	'HBYD_CP_PUXIN '
	'HBYD_CP_JYTC',
	'HBYD_CP_ TEST MGTY',
	'HBYD_CP_YINHE'
	'HBYD_CP_LUTONG');

问题 not in 不生效

  • 于是以为是mysql 官方bug ? 改用一下模式
select  source_code FROM epg.tv_program_ext_fdn where not in ( 
	"HBYD_CP_KDXFYYZQ',
	'HBYD CP HZZYWDJP',
         'HBYD CP CZSP' 
	'HBYD CP HUASHU', 
	'HBYD_CP ZLYP', 
	'HBYD CP HZZY',
	'HBYD_CP_YANHUA',
	'HBYD CP MGTY',
	'HBYD_CP WLDS'
	'HBYD_CP_ZHONGYI',
	'HBYD CP_CDCL',
	'HBYD_CP_MGIC',
	'HBYD_CP_MANGO '. 
	'HBYD_CP_SXFT',
	'HBYD_CP_SHENGJIAN'.
	'HBYD_CP_LEWEI', 
	'HBYD_CP_JUNRONG',
	'HBYD_CP_KDXE",
	'HBYD_CP_PUXIN '
	'HBYD_CP_JYTC',
	'HBYD_CP_ TEST MGTY',
	'HBYD_CP_YINHE'
	'HBYD_CP_LUTONG');

话 别说真的可以查询可以生效~~~~~

问题解决了吗? 没有 官方不能有bug~ 知道看到查询官方文档一句话 醍醐灌顶

  • not in (括号里边的字段不能有null)

如下:

  • 正确 select * from a where code not in ('a','b');

  • 错误 select * from a where code not in ('a,b');

  • 如果前端大意传错了 code = 'a,b' 就会出现问题

回到最开始的问题 ~~
  • 第三行没有逗号
and source_code not in ( 
	"HBYD_CP_KDXFYYZQ',
	'HBYD CP HZZYWDJP',
         'HBYD CP CZSP' 
	'HBYD CP HUASHU', 
posted @ 2023-03-16 09:25  vx_guanchaoguo0  阅读(117)  评论(0编辑  收藏  举报