mysql select multiple rows in join

Posted by julio on Stack Overflow See other posts from Stack Overflow or by julio
Published on 2010-04-29T21:08:00Z Indexed on 2010/04/29 21:17 UTC
Read the original article Hit count: 128

Filed under:
|
|

Hi-- I have a simple mySQL problem--

I have two tables, one is a user's table, and one is a photos table (each user can upload multiple photos).

I'd like to write a query to join these tables, so I can pull all photos associated with a user (up to a certain limit).

However, when I do something obvious like this:

SELECT *.a, *.b FROM user_table a
  JOIN photos_table b ON a.id = b.userid

it returns

a.id, a.name, a.email, a.address, b.id, b.userid, b.photo_title, b.location

but it only returns a single photo. Is there a way to return something like:

a.id, a.name, a.email, a.address, b.id, b.userid, b.photo_title, b.location, b.id2, b.photo_title2, b.location2 etc. . .

for a given LIMIT of photos?

Thanks for any ideas.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about join