發生條件:
in語法,裡面超過 1000 個要查詢內容
例如
Select * from tablename where col in (‘col1’,’col2’ ……..)
要避開這個問題發生,可以考慮使用:
(1).Union語法:
select * from student
where id in ('1147', '1148', '1149', '1151', '1152', '1154', ...)
union
select * from student
where id in ('1157', '1158', '1159', '1161', '1162', '1164', ...)
(2).創建一個臨時Temp,將這些查詢資料,放進來這個臨時Temp:
select * from student where id in (select id from tmp_XX);
(3)將in 的語法拆開成數段
Select * from tablename where col in (‘col1’,’col2’ …….., ‘col1000’) or col in (‘col1001’, …………)
沒有留言 :
張貼留言