I am trying to get all users that have no value set for fid = 13, or no value at all in profile_values. I guess this is a simple solution, but I just don't see it. Any help or point in the right direction is welcome.
(Table users and value profiles are both from Drupal.)
Simplified Values:
uid name fid value 1 user1 1 foo 1 user1 2 foo 2 user2 12 2 user2 13 1265662514 3 user3 NULL NULL 4 user4 NULL NULL
What I tried:
SELECT u.uid, u.name, pv.fid, pv.value FROM users u LEFT JOIN profile_values pv ON pv.uid = u.uid WHERE u.status != 0 AND (pv.fid != 13 OR pv.fid IS NULL) GROUP BY u.uid uid name fid value 1 user1 1 foo 2 user2 12 foo 3 user3 NULL NULL 4 user4 NULL NULL
My problem is user2, which should not be, as it matters in fid = 13
Thanks for all the incredible quick and qualified answers, greetings!
source share