我有以下查询:
select * from rootTable rt
where
(select pk
from someConfigTable
where col1='someValue') = any(select confRef from t where t.r = rt.r)
and rt.pk = 123
(select pk from someConfigTable where col1='someValue')
返回一些数字 3456789
select confRef from t where t.r = rt.r
返回一些数字集合 3456789, 3456789
someConfigTable.pk
和 t.confRef
的类型为 bigint(20)
但由于某种原因查询没有返回任何行!
但是,当我用常量替换 (select pk from someConfigTable where col1='someValue')
时,它可以正常工作并返回一些行:
select * from rootTable rt
where 3456789 = any(select confRef from t where t.r = rt.r) and rt.pk = 123
问题是什么???
显示“%version%”等变量
# Variable_name, Value
innodb_version, 5.6.16
protocol_version, 10
slave_type_conversions,
version, 5.6.16
version_comment, MySQL Community Server (GPL)
version_compile_machine, x86_64
version_compile_os, Win64
最佳答案
select * from rootTable rt
where (select pk from someConfigTable where col1='someValue') in (select confRef from t
where t.r = rt.r) and rt.pk = 123
试试这个:)但我不能100%确定它会正常工作???
关于mysql in/=any 带有子查询的运算符的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25161264/