I am trying to exclude a list of Names in an
I have the table Names
id| Name | Surname
---------------------
1 | Michael | Kane
2 | Torben | Dane
3 | Dinge | Chain
4 | Django | Fain
5 | Juliett | Bravo
And i have the Table Excludes
id| Name
-----------
1 | Michael
2 | Torben
Now I have two queries:
SELECT * From Names, Excludes
WHERE Names.Name = Excludes.Name
GROUP BY Names.Name
which results in
id | Name | Surname | id | Name
--------------------------------
1 | Michael | Kane | 1 |Michael
2 | Torben | Dane | 2 |Torben
Now i want to do the exact opposite with !=
to do the actual purpouse and erase the lines which have the names Michael
and Torben
in it
The seconds query is:
SELECT * From Names, Excludes
WHERE Names.Name != Excludes.Name
GROUP BY Names.Name
The Result is
id | Name | Surname | id | Name
--------------------------------
3 | Dinge | Chain | 2 |Torben
4 | Django | Fain | 2 |Torben
5 | Juliett | Bravo | 2 |Torben
1 | Michael | Kane | 2 |Torben
2 | Torben | Dane | 1 |Michael
The Result I would want to have is
id| Name | Surname
---------------------
3 | Dinge | Chain
4 | Django | Fain
5 | Juliett | Bravo
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire