Jump to content

[SOLVED] MYSQL Query HELP


rocoso

Recommended Posts

Hi

This query will select email address of members that have a picture.

SELECT email FROM users a, useralbum b WHERE a.user_id=b.zuserid AND b.picnumber ='1'

 

I would like to select email addresses of members who do not have a picture.

b.picnumber ='0'  or something like that is not going to work because if they never uploaded a picture they have no records in the useralbum table.

 

Thanks :)

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/75890-solved-mysql-query-help/
Share on other sites

Here you go

 

SELECT email FROM users where userid not in (select user_id from useralbum)

 

rajivgonsalves, based on rocoso post it would be this:

 

SELECT email FROM users where user_id not in (select zuserid from useralbum)

 

 

Also, here's another way:

 

SELECT
             u.email
   FROM
             `users` u
   LEFT JOIN
             `useralbum` ua
     ON
             ua.zuserid = u.user_id

WHERE   
             ua.zuserid IS NULL
;

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.