两张桌不相等

Wil*_*l_S 2 php

我有一个SQL查询,这里是我坚持的部分.

$query = "SELECT DISTINCT user.firstname, user.lastname, user.userid FROM user, staff WHERE user.type = 'Staff' AND staff.userid!= user.userid";
Run Code Online (Sandbox Code Playgroud)

出于某种原因,它只打印出用户所在的部分,但是!=不起作用,好像我删除了!并且只有staff.user_id = user.user_id它可以工作并打印出这两个表中的所有用户?

有人可以解释为什么会发生这种情况并找到解决方案.

编辑

TABLE USER                       TABLE STAFF
ID - NAME - TYPE                ID   -     NUMBER
1  - A    - Staff               1    -      11111
2  - B    - Staff               2    -      22222
3  - C    - Customer
4  - D    - Customer
5  - E    - Staff
6  - F    - Staff
Run Code Online (Sandbox Code Playgroud)

我如何找到用户ID 5和6?

dgw*_*dgw 7

尝试<>而不是!=.

已编辑问题的编辑答案:

SELECT user.firstname, user.lastname, user.userid 
FROM user LEFT JOIN staff ON user.userid=staff.userid 
WHERE user.type = 'Staff' AND staff.userid IS NULL ;
Run Code Online (Sandbox Code Playgroud)