我有一个sql-select(或插入),它使用相同的两个参数多次。 有没有办法避免对列表中的每个“?,?,?,?,...”使用多个相同的参数?多次使用相同的参数
cursor.execute(statement, list)
我可以想到两个命名参数,但没有代码注入的可能性。
在下面的例子中,每个左边的“?” RESP。对 ”?”是相同的字符串。为了得到一个结果,我在一个陈述中使用了七项计数。
select count(case (aart like "1%") and (adatum between ? and ?) when 1 then 1 else null end) as AufExt,
count(case (aart like "1%E") and (adatum between ? and ?) when 1 then 1 else null end) as AufExtE,
count(case (aart like "1%K") and (adatum between ? and ?) when 1 then 1 else null end) as AufExtK,
count(case (aart like "2S%") and (adatum between ? and ?) when 1 then 1 else null end) as AufInt,
count(case (eart like "3%") and (edatum between ? and ?) when 1 then 1 else null end) as EntExt,
count(case (eart like "3%K") and (edatum between ? and ?) when 1 then 1 else null end) as EntExtK,
count(case (eart like "2S%") and (edatum between ? and ?) when 1 then 1 else null end) as EntInt
from tabelle
对此问题的相关问题:它看起来好像没有索引用于“情况”。正确?
simpler:'sum((eart like'1%')and(adatum between?and?))' –
这个工程!谢谢 –