我希望在满足案例时用更多条件评估一行。
以下是我提出的建议:
SELECT ... FROM ...
WHERE Events.CALENDAR_ID + "=?
AND case when " + Events.DTEND + ">0
then " + Events.DTSTART + ">? end";
但是,此语句忽略了不满足该情况的行。
SELECT ... FROM ...
WHERE Events.CALENDAR_ID + "=?
case when " + Events.DTEND + ">0
then AND " + Events.DTSTART + ">? end";
然后我想出了这个,但Sqlite告诉我这只是错误的语法。
正确的语法是什么?
答案 0 :(得分:0)
正确的语法是:
SELECT ... FROM ...
WHERE "case when " + Events.DTEND + ">0 " +
" then " + Events.CALENDAR_ID + "=? AND " + Events.DTSTART + ">? " +
" else " + Events.CALENDAR_ID + "=? end"