Request with EXCEPT causes an error

MySQL keeps throwing errors when I try to use SQL exceptin my query ...

Why doesn't it work? What is wrong with him?

select name, email from users
except
select name, email from users_ban
+4
source share
1 answer

As far as I know, MySQL does not support the statement except. You can use a query with a correlated predicate not existswith the same effect as this:

SELECT DISTINCT *
  FROM users
  WHERE NOT EXISTS ( 
                    SELECT 1
                      FROM users_ban
                      WHERE users.name
                            = 
                            users_ban.name
                        AND users.email
                            = 
                            users_ban.email );

SQL script example

+1
source

All Articles