Does MySQL Short Circuit the IF() function?

前端 未结 4 964
Happy的楠姐
Happy的楠姐 2021-01-18 15:05

I need to query data from a second table, but only if a rare set of conditions in the primary table is met:

SELECT ..., IF(a AND b AND c AND (SELECT 1 FROM t         


        
4条回答
  •  不思量自难忘°
    2021-01-18 15:29

    Try it in the SQL analyzer. If you want to be on the safe side and not have to trust the database to work one way (and not to change that behavior ever in new versions), just make two queries and do the IF programmatically.

提交回复
热议问题