The NOT keyword
Parte da seção Fundamentos do Journey de SQL da Coddy — lição 8 de 72.
O palavra-chave NOT significa que não queremos que a condição seja atendida.
Por exemplo, considere a seguinte tabela <strong>people</strong>:
| name | age | gender |
|---|---|---|
| Joas | 13 | male |
| Holwa | 17 | male |
| Nohlas | 24 | female |
| Polar | 23 | male |
| Loopa | 18 | female |
SELECT *
FROM people
WHERE NOT gender = 'male'Este será o resultado:
| name | age | gender |
|---|---|---|
| Nohlas | 24 | female |
| Loopa | 18 | female |
O palavra-chave NOT basicamente inverte a condição. Por exemplo, as seguintes consultas são idênticas:
WHERE age > 20WHERE NOT age <= 20Desafio
FácilTabelas e colunas disponíveis:
<strong>people</strong>:<strong>name</strong>,<strong>age</strong>,<strong>status</strong>
Busque todas as pessoas onde o status NÃO é retired
Experimente você mesmo
SELECT *
FROM PEOPLE
-- Escreva seu código abaixo
WHEREEsta lição inclui um quiz rápido. Comece a lição para respondê-lo e acompanhar seu progresso.
Todas as lições de Fundamentos
4More Keywords
The IN keywordThe BETWEEN keywordThe LIKE keywordThe AS keywordRecap - Cellphone Models2Conditions
Conditions BasicsThe AND keywordThe OR keywordThe NOT keywordMultiple Conditions CombinedParenthesisBooleans5Arithmetic Operations
Mathematical OperatorsMathematical ColumnsThe Modulo OperationThe ROUND() Function3Specific Return Format
Null valuesSort Results Part 1Sort Results Part 2Recap - Cyber Security FirmLimit number of recordsRecap - Vehicle Factory6Intro Challenges
Recap - Parliamentary ElectionRecap - Police Criminal ArrestRecap - Bar Beverage ContainerRecap - Engineer new columns