MySQL query : all records of one table plus count of another table

Posted by Ricardo on Stack Overflow See other posts from Stack Overflow or by Ricardo
Published on 2010-05-15T10:26:44Z Indexed on 2010/05/15 10:34 UTC
Read the original article Hit count: 236

Filed under:
|

Hello Guys! I have 2 tables: User and Picture. The Picture table has the key of the user. So basically each user can have multiple pictures, and each picture belongs to one user. Now, I am trying to make the following query: I want to select all the user info plus the total number of pictures that he has (even if it's 0). How can I do that? Probably it sounds quite simple, but I am trying and trying and can't seem to find the right query. The only thing I could select is this info, but only for users that have at least 1 picture, meaning that the Pictures table has at least one record for that key... But I also wanna consider the users that don't have any. Any idea? Thanks!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query