-3

I used select in if for example :

select IF (LEAVETYPE = 1 , (select test1,test2 from TableName),(select test3,test4 from TableName where id = 2) 
FROM TableName

I Wanne Used Select in IF

F0XS
  • 1,271
  • 3
  • 15
  • 19

1 Answers1

2

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