> > Hello,
> > I have 2 tables users table, that stores user info, and photos table,
> > i want to select all users with one photo form photos table, but i don't
> > want it to be photos * users = result.
> > Is there way to do it?
> Assuming you mean, you have a table called user_info and another called
> photos and each of them has a common element AND there must be a photo for
> the user then you could use this sort of select...
> select user_info.name, photo.image from user_info, photo where
> = photo.user_id
> The above will not display anything if there are no matching id to user_id
> so if one of your users didn't have a photo they would not get displayed.
> Also, if a user had more than one photo they would all be displayed.
> If your users are expected to have one and only one photo then you may
> get rid of the photo table and just put the photo in the user table.
Thank You for your reply, but the problem is that users may have many
photos, and i need to get only one, i use folllowing sql:
SELECT users.username, photos.file FROM users left join photos on
And i get:
but i want only 3 users from this join, not 3x3=9
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php