2
Considering this scheme
CREATE TABLE bra_ocorrencias (
estado varchar2(2),
genero varchar2(1),
ano number,
nome varchar2(30),
num_ocorrencia number
);
I need to make a query that returns me the most registered name by women in the state of SP, MG and RJ from 2006 to 2012. So I wrote it that way
SELECT nome
FROM bra_ocorrencias
WHERE genero LIKE 'F'
AND estado LIKE 'SP' AND estado LIKE 'MG' AND estado LIKE 'RJ'
AND ano BETWEEN 2006 AND 2012
The query has no syntax errors, it returns me results but not according to the proposed logic, someone can see the error in the relational logic of my syntax in relation to the query rule given above?
There is a significant difference between using the '=' pro LIKE?
– Rafael Brito
@Rafaelbrito
LIKE
is useful when you want to look for a pattern instead of the exact value. Ex:estado LIKE 'S%'
search all states that start withS
. As in your case you are seeking the exact values (SP, MG, RJ), there is no need to useLIKE
.– hkotsubo