With one select command, display all cats with male sex and dogs whith female sex
i'have tried select * from pet where species='cat' && sex='m' | species='dog' && sex='f';
With one select command, display all cats with male sex and dogs whith female sex
i'have tried select * from pet where species='cat' && sex='m' | species='dog' && sex='f';
You connect boolean expressions in SQL using AND and OR, not strange operators lifted from C:
where (species = 'cat' and sex = 'm') or
(species = 'dog' and sex = 'f');
MySQL also supports IN with tuples:
where (species, sex) in ( ('cat', 'm'), ('dog', 'f') );
And just to clarify: MySQL does understand && and || as real boolean operators. I strongly discourage anyone from using this (mostly my general preference for standards when they are equivalent). However, & and | are bitwise operators, so they may not do what you expect in a boolean context.