Jump to content

SELECT one uinique field from MySQL


only1perky

Recommended Posts

Hi Guys,

 

Can someone please help me before I kill myself!

 

I have a table holding details of images to be displayed in a gallery.

The table has columns as 'id', 'image_caption', 'file_path', and 'userid'.

 

The 'id' column is the unique key, and the 'userid' column is obviously id of the user who uploaded the image.

 

What I would like to do is select and display one image from each unique userid and then display each image along with the details in my gallery. It doesn't really matter which users image is selected aslong as there is only one for each unique user.

 

I have been trying a number of ways to do this (DISTINCT / subqueries) but I just cant get anything to work.

Could someone please advise me on how I could get this to work.

 

Cheers in advance.

 

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.