1、视图与IN、EXIST不能共用,且不报错

一条视图与IN、EXIST同时存在的语句,本该查出数据,但一直结果为空,且没有报错。同样的语句、同样的数据源,在mysql8中可支持查出数据。

select * 
from view_alarm_info 
where pkid IN (
	SELECT tb_datax_etl_mysql_middle.pkid
	FROM tb_datax_etl_mysql_middle
)

还原成原sql后,却可正常查出数据

select * 
from (
	SELECT
	bis_fire_alarm.pkid,
	sys_ptz.ptz_lon,
	sys_ptz.ptz_lat,
	bis_fire_alarm.ptzid AS ptz_id
	FROM bis_fire_alarm
	INNER JOIN sys_ptz ON sys_ptz.ptz_id = bis_fire_alarm.ptzid
) a
where pkid IN (
	SELECT tb_datax_etl_mysql_middle.pkid
	FROM tb_datax_etl_mysql_middle
)

 因此我推测是因为“mysql5.x中不支持视图与IN、EXIST不能共用,且不报错”

05-12 10:02