I have some problems with an (My)SQL query. In my DB I have two tables. One is called kfz_typen, the other kfz_temp2. I need to get all entries of the kfz_temp2 table, which ktyp (just an integer field) is not in the kfz_typen table.
SELECT * FROM kfz_temp2
WHERE kfz_temp2.KType NOT IN (SELECT DISTINCT kfz_typen.ktyp FROM kfz_typen)
In my opinion this query above should exactly do, what I want. But it doesn’t! I just get an empty result back from my MySQL Server.
Without the “NOT” in the Query, I get the entries that are in both tables, so the matching does work.
So what’s wrong with the Query above?
Would this work?
You may need to group the result.
I’m unsure why the first query doesn’t work, but I believe this does the same thing.