View Single Post
  #1 (permalink)  
Old January 20th, 2005, 11:46 PM
leo_vinay leo_vinay is offline
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in query

Hi all !
I have two tables

Users Table:
UserId(Primary Key)
username
fname
email


Photos table:
photoid (Primary Key)
UserId (ForeignKey)
photoname
isactivated

In the photos table each user may have records varying from 1 to 3 (i.e max 3 photos).
But i need a query to retrieve a single record of each user from photos as well his username,fname and email from Users table.
Code:
select distinct (Photos.UserId),photoname,isactivated,username,fname,email from
photos,users where photos.UserId=users.UserId
The above query doesn't work and fetches multiple photos of each user
as each record happens to be distinct because the photoname in all of them is different.

I need each users sigle photo record along with his user table details.

Thanks in advance.

Vinay
Reply With Quote