Select Query to check both or either or condition

后端 未结 2 1574
栀梦
栀梦 2021-01-26 05:21

I\'m using postgresql 9.1 and wish to select a single record from table. Details are as below :

table name : muser

fields present in table : userid,username,fir

2条回答
  •  醉梦人生
    2021-01-26 05:42

    When I'm dealing with filter where the value can be any including null I'll try add coalesce()

    SELECT userid, mailid, phonenumber 
    FROM muser 
    WHERE coalesce(phonenumber,'no data') = coalesce(?,'no data') 
    OR coalesce(mailid,'no data') = coalesce(?, 'no data');
    

提交回复
热议问题