I want to set a query which asks "show me all people from table users which are not found in table employees". Im looking for unemployed people
SELECT user.name,user.surname,user.user_id,employee.employee_id,employee.user_id FROM user INNER JOIN employee ON employee.user_id=user.user_id WHERE user.user_id <> employee.user_id
Tables are linked via
You can do this sort of query using an
outer join, and checking for a null value in the outer table.
Here is a slight modification of your query, changing it to an outer join, and looking for a null value being returned.
Edit: I've also added in a third table, containing the
manager table, as per the comment to this answer.
SELECT user.name,user.surname,user.user_id,employee.employee_id,employee.user_id FROM user LEFT OUTER JOIN employee ON employee.user_id=user.user_id LEFT OUTER JOIN manager ON manager.user_id=user.user_id WHERE -- The columns from employee and manager get returned with null values if there is no match employee.user_id is null and manager.user_id is null
- mysql inner join too slow
- how to self join a table and get the records
- value of max_connections in AWS RDS
- How to delete specific models in Yii2?
- JOIN and COUNT wrong result
- MySQL: INSERT INTO SELECT issues
- SQL search for words in any order
- “Column 'id' in where clause is ambiguous” after inner joining?
- How to search for duplicates with cutting of a specified value
- How to join two table and show one query result in MySQL?
- Section 188.8.131.52, “mysql Client Options” Secti
- Section 184.108.40.206, “mysql Client Options” cd
- ", Schema Object Names mysql50 identifier prefix, Schema O
- d in MySQL 5.7.6. * `mysql_firewall_mode`: Whether MySQL
- res account rows in the `mysql.user` system table to have a
- backups produced by the `mysqlbackup` command of the MySQL E
- es and Tables 3.5 Using mysql in Batch Mode 3.6 Examples o
- in `%userprofile%\MySQL\mysql-sandboxes` on the local host.
- Section 220.127.116.11, “mysql_session_track_get_first()”
- Section 4.6.7, “mysqlbinlog — Utility for Process