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:

  1. display record when both present

  2. display record when mailid present

  3. 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

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -