Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with tricky select statement

Status
Not open for further replies.

cb49747

MIS
Apr 23, 2002
181
US
I have two tables containting user data. The first table has one record for every user. The second table can have 0 to multiple records per user depending on the programs they have access to.

I want to display every user and place a flag next to the ones that have access to the administration program. I use the query below and it sort of works.

SELECT investor_login.username, investor_login.firstname, investor_login.lastname, investor_login.status, investor_login.lastlogondate, investor_prg.program FROM investor_login LEFT JOIN investor_prg ON investor_login.username = investor_prg.username WHERE investor_login.investornumber = '$myinvestor' AND (investor_prg.program = 'admin.pl' OR investor_prg.program IS NULL) $order

This will give me a list of all users who have access to no programs or access to the admin program. However if someone has access to a program other than the admin one they are not selected.

Anyone have any ideas?

THanks
 
Code:
SELECT investor_login.username
     , investor_login.firstname
     , investor_login.lastname
     , investor_login.status
     , investor_login.lastlogondate
     , investor_prg.program 
  FROM investor_login 
LEFT 
  JOIN investor_prg 
    ON investor_prg.username = investor_login.username 
   [b]AND[/b] investor_prg.program = 'admin.pl' 
 WHERE investor_login.investornumber = '$myinvestor' 
$order

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top