1

我有一个包含条件的 SQL 语句,在条件内部有一个查询。如果条件不成立,是否仍会评估查询?还是 MySQL 会根据需要“懒惰地”评估子查询?

样本有子句

HAVING
    IF(NOT isConfirmed, IF(
       IFNULL((SELECT SUM(net) as net from invoices where `to_id` = 5), 0)
       > 0
    , 1, 0) -- if its not confirmed, make sure total_paid total is greater than 0
, 1) -- otherwise dont care
4

0 回答 0