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
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
;

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.