vendredi 1 septembre 2017

SQL - if statement only

I need to set if-statement without else part in SQL query. But if-statement syntax is IF(<condtion>, <true part>, <false part>). I do not have (not need to set) any value for else part.

Example: From user table, if user id is greater than 0 then only I need to add user id. How can I implement/add such condition?

SELECT
    u.fname,
    u.lname,
    IF(u.id>0, u.id, ? )  // Here I do not have value for else part.
FROM
    user_table u;

Aucun commentaire:

Enregistrer un commentaire