List:General Discussion« Previous MessageNext Message »
From:David T. Date:September 17 2004 6:33pm
Subject:Problems with Left Join query
View as plain text  
I am building a database with permissions for different modules. The
permissions table contains a separate row for each module/user combination, and
lists the add/mod/del permissions for that module. So, for example, user 'bob'
might have add and del rights for 'module1', add only rights for 'module2', and
no rights for 'module3'. The rows in permissions would be:

ID | USER | MODULE     | ADD | MOD | DEL
----------------------------------------
1  | bob  | module1    |  1  |  0  |  1  
2  | bob  | module2    |  1  |  0  |  0

But, I need to build an entry form that lists all of the modules in the modules
table and loads in the permissions for that user. I was believing that I could
write a single LEFT JOIN query that would give me all the modules and
permissions in one single pass. However, when I build the query, it only
returns the user records. I have tried:

SELECT modules.mod_name, permissions.* 
FROM permissions 
LEFT JOIN modules ON
permissions.module = modules.mod_name 
WHERE permissions.user='bob'

What am I doing wrong?

Cheers,
David


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
Thread
Problems with Left Join queryDavid T.17 Sep
  • Re: Problems with Left Join queryGreg Donald17 Sep
  • Re: Problems with Left Join queryRhino17 Sep
    • displaying MySQL query results differentlygowthaman ramasamy20 Sep
  • Re: Problems with Left Join queryMichael Stassen17 Sep