现有一SQL语句:
select columnA from table where columnB in ('2009-05-01 00:00:00', '2009-05-01 01:00:00',......)
其中括号中的字符串是程序自动生成的,有时会出现超过65,536,SQL语句就不能执行。
除了语句拆分,是否有其它解决方法?
...全文
50813打赏收藏
SQL 语句过长如何处理
现有一SQL语句: select columnA from table where columnB in ('2009-05-01 00:00:00', '2009-05-01 01:00:00',......) 其中括号中的字符串是程序自动生成的,有时会出现超过65,536,SQL语句就不能执行。 除了语句拆分,是否有其它解决方法?
select columnA from table where columnB
in (select qdate from
(
select '2009-05-01 00:00:00' as qdate
union all select '2009-05-01 01:00:00'
union all select ......
) t
)
in有64k限制,sql应该没有
in ('2009-05-01 00:00:00', '2009-05-01 01:00:00',......)
改为
join (select '2009-05-01 00:00:00' f1
union select '2009-05-01 01:00:00'
union ......
) d on d.f1=...