Pseudo SQL ahead:
SELECT *
FROM table
WHERE(if var1=a then var2 must=b)
AND (if var2=c then var3 must=d);
The query would return both rows with var1=a and var2=b that match the conditions, as well as all rows where var1 != a and where var2 != c.
Without using IF, using OR would ignore one of the conditions, and using AND would enforce all the conditions on each row.
Aucun commentaire:
Enregistrer un commentaire