I have the following table:
id_usuario | idioma | certificado
________________________________________
12 | Español | Si
12 | Francés |
12 | Alemán | Si
13 | Español |
13 | Inglés |
14 | Inglés | Si
14 | Alemán |
15 | Inglés | Si
16 | Italiano |
When I want to show users who have at least one certified language, I perform the following query:
SELECT DISTINCT(id_usuario) FROM myTable where certificado='Si'
And the result:
id_usuario |
_____________
12 |
14 |
15 |
But now I want to get the users who don't have any certified language, I have tried by doing this query:
SELECT DISTINCT(id_usuario) FROM myTable where certificado!='Si'
But I get these results:
id_usuario |
_____________
12 |
13 |
14 |
16 |
And I want to get this:
id_usuario |
_____________
13 |
16 |
How do I make the change to the query?
I will appreciate your answer.
you can compare the amount with the total number of records with the "if" that is less than 1 or ==0
example
you could try
Since there are no records, the field is null. So you could include the condition if it is null) Greetings!
Use a subquery and avoid filtering by comparing the number of records.
In the end you get exactly the information you need.