Using an IF Statement in a MySQL SELECT query

前端 未结 3 1881
无人及你
无人及你 2020-11-27 18:30

I am trying to use an IF statement in a MySQL select query.

I am getting an error after the AND statement where the first IF

3条回答
  •  半阙折子戏
    2020-11-27 18:53

    try this code worked for me

    SELECT user_display_image AS user_image,
           user_display_name AS user_name,
           invitee_phone,
           (CASE WHEN invitee_status = 1 THEN "attending"
                 WHEN invitee_status = 2 THEN "unsure"
                 WHEN invitee_status = 3 THEN "declined"
                 WHEN invitee_status = 0 THEN "notreviwed"
           END) AS invitee_status
      FROM your_table
    

提交回复
热议问题