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
https://forums.phpfreaks.com/topic/221128-select-one-uinique-field-from-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.