Mysql
 sql >> Database >  >> RDS >> Mysql

Query MySQL con istruzione condizionale?

Potresti usare questo semplice test:

WHERE (requires = 'privacy-weight' AND privacy-weight = 0) OR requires <> 'privacy-weight' OR requires IS NULL

La prima parte (requires = 'privacy-weight' AND privacy-weight = 0) impedisce l'output di:

privacy-weight | requires
-------------------------
1              | privacy-weight

Ma mantiene:

privacy-weight | requires
-------------------------
0              | privacy-weight

Mentre la seconda parte OR requires <> 'privacy-weight' OR requires IS NULL manterrà i seguenti:

privacy-weight | requires
-------------------------
0              | NULL
1              | NULL
1              | NULL