我创建了 Mysql 函数,它给出结果整数或 NULL。它适用于所有值。如果在简单查询中使用此函数,它也可以按预期工作,如下查询:
select distinct(hsd.hotel_id)
from hotel_season_detail hsd
where '2019-04-26' BETWEEN hsd.season_fromdate and hsd.season_todate and hsd.stop_sale >'2019-04-26' and getHotelMarkupManagementId(hsd.id,'AFG') is NOT NULL
getHotelMarkupManagementId()
是用户定义的mysql函数。如上查询返回酒店表中已存在的两个酒店 ID。
但是当这个查询添加为子查询时
select * from hotel_service
where id in
(select distinct(hsd.hotel_id)
from hotel_season_detail hsd where '2019-04-26' BETWEEN hsd.season_fromdate and hsd.season_todate and hsd.stop_sale >'2019-04-26' and getHotelMarkupManagementId(hsd.id,'AFG')
is NOT NULL)
它给出了错误的结果。它没有按预期工作。
select * from hotel_service where id in (125,126)
给出结果,如果单独运行,子查询也会给出 id 125 和 126 作为结果。但是当作为子查询添加时它会失败
这种行为是否应该归因于mysql function
inIN
子句?请建议。