How to used select in if

This question already has an answer here:

  • How do I perform an IF…THEN in an SQL SELECT? 22 answers

  • This question is already asked. You can find the answer here: https://stackoverflow.com/a/63480/8713889

    You should use CASE. Example from the mysql doc:

        CASE case_value
            WHEN when_value THEN statement_list
           [WHEN when_value THEN statement_list] ...
           [ELSE statement_list]
        END CASE
    

    Reference: https://dev.mysql.com/doc/refman/5.7/en/case.html

    链接地址: http://www.djcxy.com/p/94352.html

    上一篇: mssql这是语法'if'

    下一篇: 如何在if中使用select