sql - Select Query to check both or either or condition -
i'm using postgresql 9.1 , wish select single record table. details below :
table name : muser
fields present in table : userid,username,firstname,lastname,phonenumber , mailid
fields selected : userid, mailid, phonenumber
request parameter : mailid , phonenumber
conditions should satisfied:
display record when both present
display record when mailid present
display record when phonenumber present.
expected output:
single record (as userid unique) userid, phonenumber , mailid
both or 1 if present.
i have tried query :
select userid, mailid, phonenumber muser phonenumber = ? or mailid = ?
it's working fine first 2 conditions not working last condition..when fire query last condition gives records present in query.why so? changes in query? or else
assuming when mean "not present", mailid or phonenumber null
in database,
select userid, mailid, phonenumber muser (phonenumber = ? , (mailid null or mailid = '')) or ((phonenumber null or phonenumber = '') , mailid = ?) or (phonenumber = ? , mailid = ?)
Comments
Post a Comment