TABLE GROUP
group_id | user_id
1 1
TABLE USERS
user_id | fullname
1 Juan dela Cruz
2 Maria
I’m displaying the result in my table users
using a foreach loop but what I want is when the user_id
in my table group
exists I don’t want it to display anymore. How can i achieve that? I know that I need to cross table but don’t know where to start also I’m thinking using an INNER JOIN
but it will just merge the same user_id
into 1.
SELECT * FROM users WHERE user_id NOT IN(SELECT user_id FROM group)
If i understand you right:
SELECT * FROM users WHERE user_id <> <ID>
select distinct u.user_id, u.fullname
from USERS u
left outer join GROUP g on u.user_id = g.user_id
where g.user_id is null