The reason it doesn't return NULL is NULL is never LIKE 'username'
CompMan86 wrote:
Two tables, groups and user_permissions.
Groups is indexed by groupid as primary key. User_permissions is indexed
by username and groupid.
For each user that's in a group, a row in user_permissions exists.
I want to select from groups and user_permissions looking for a certain
user in user_permissions. If there is no such user in that group, I want
it to return null.
The reason left join doesn't work is because as long as there is at
least one user in the group, it won't return null for username.
Here's the query that doesn't work:
SELECT * FROM groups LEFT JOIN user_permissions USING (groupid) WHERE
groups.groupid=5 AND user_permissions.username LIKE 'username';
Thanks for any and all help!
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php