Combining conditions
A WHERE clause can test more than one thing at once. Join conditions with:
AND— both must be trueOR— at least one must be trueNOT— flips a condition
This returns 11A students who also scored above 88.
Combinando condições
Uma cláusula WHERE pode testar mais de uma coisa ao mesmo tempo. Junte condições com:
AND— ambas devem ser verdadeirasOR— pelo menos uma deve ser verdadeiraNOT— inverte uma condição
SELECT name FROM student WHERE form = '11A' AND score > 88;
Isso retorna alunos da turma 11A que também tiraram acima de 88.
Mixing AND and OR
When you mix AND and OR, use brackets to make the meaning clear, just like in maths:
AND is checked before OR, so brackets remove any doubt about what you mean.
Misturando AND e OR
Ao misturar AND e OR, use parênteses para deixar o significado claro, assim como na matemática:
SELECT name FROM student
WHERE form = '11B' OR score >= 95;
AND é avaliado antes de OR, então os parênteses eliminam qualquer dúvida sobre o que você pretende.
Common mistakes
- Use brackets when you mix
ANDandORto make the order clear. NOTreverses a condition.
Erros comuns
- Use parênteses ao misturar
ANDeORpara deixar a ordem clara. NOTinverte uma condição.
AND, OR, NOT
Combine conditions with AND/OR/NOT — see the truth table. · Combine condições com AND/OR/NOT — consulte a tabela-verdade.
Show the name of every student who is in form 11A and · e scored more than 88. · Exiba a name de todos os alunos que estão na turma 11A e obtiveram nota superior a 88.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Show the name of every student who is in form 11B or · ou scored 95 or more. · Exiba a name de todos os alunos que estão na turma 11B ou obtiveram nota 95 ou mais.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.