且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

案例在教义查询构建器where子句中不起作用

更新时间:2023-10-23 14:10:34

您在 WHERE 中的 CASE 表达式是错误的。您可以将其转换为正常的复合条件,例如

Your CASE expression in WHERE is wrong. You could convert it to normal compound condition like

(CASE WHEN a.ephemeral = 1 THEN a.date_beginning < NOW() AND a.date_ending > NOW()ELSE a.ephemeral = 0 END)

To

SELECT * FROM ride
WHERE ((a.ephemeral = 1 
       and a.date_beginning < NOW() 
       AND a.date_ending > NOW()) 
  OR a.ephemeral = 0)
  AND a.active = 1 
  AND a.status = 5
ORDER BY `date_ending` DESC