I have a SQL query and here it is the part I’m stuck on.
$query = "SELECT DISTINCT user.firstname, user.lastname, user.userid FROM user, staff WHERE user.type = 'Staff' AND staff.userid!= user.userid";
For some reason, it only prints out the part where users are staff but the != is not working, where as if I remove the ! and only have staff.user_id = user.user_id it works and prints out all users that are in both of those tables?
Can someone please explain why is this is happen and have a solution.
EDIT
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
How would I find the users id 5 and 6?
Try
<>instead of!=.Edited answer for the edited question: