My tables
- users
id | name |
---|---|
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |
My Answer:
groups____id_name_____Cell 1_Cell 2___Cell 3_Cell 4____
memberships__id_user_id_group
You can achieve this by using a SQL query with a LEFT JOIN and a WHERE clause to filter out the users who are members of the group with id=6. Here's an example query:
php
SELECT u.id, u.name
FROM users u
LEFT JOIN memberships m ON u.id = m.id_user
WHERE m.id_group <> 6 OR m.id_group IS NULL;
This query will select all users who are not members of the group with id=6. The LEFT JOIN ensures that all users are included in the result set, even if they do not have a corresponding membership record. The WHERE clause filters out the users who are members of the group with id=6.
Rate this post
3 of 5 based on 5267 votesComments