mysql - SELECT query with if statement? -


i have table following example information in php script:

 custid name type date 1      roy     20150715 1      roy  -c   20150715 2      bart b    20150715 

in select query want customers type = , type = b if type = -c want remove a or b query.

if need select records customers don't have type '-c' on any row first need find customers want exclude. can done following query:

select custid yourtable `type` = '-c'; 

now should able find other customers:

select * yourtable   custid not in (   select custid yourtable `type` = '-c'  ); 

above 1 way achieve this. can use temporary table or join against above subquery.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -