Unique Image Query

Unique Image Query

am 23.08.2007 09:01:23 von Steve

Hi,

I am having trouble achieving the outcome I am looking for with a mysql
query.

The query below pulls information from two tables: profile_images and
name_list.

It pulls 6 random images where the name_list.id matches the
profile_images.vref but also checks that the 'class' field from name_list is
equal to '5'.

$index_thumbs = mysql_query("SELECT DISTINCT * FROM profile_images,
name_list
WHERE profile_images.vref = name_list.id AND name_list.class = '5'
ORDER BY RAND() LIMIT 0,6");


This is working fine for pulling 6 random images that meet those
requirements but I would also like to to make the profile_images.vref /
name_list.id UNIQUE as there are multiple images for each each
name_list.id - So therefore I would like to return 6 unique images from 6
id's in the name_list rather than having cases where multiple images show up
from one name_list.id

I'm hoping this is going to be a simple adjustment to someone who knows what
they're doing :)

Thanks in advance.

Steve

Re: Unique Image Query

am 23.08.2007 18:19:49 von Shion

Steve wrote:

> I'm hoping this is going to be a simple adjustment to someone who knows what
> they're doing :)


You could try to GROUP BY on name_list.id.


--

//Aho

Re: Unique Image Query

am 24.08.2007 03:41:47 von Steve

Perfect :)


Thanks


"J.O. Aho" wrote in message
news:5j5qd6F3sd2j7U1@mid.individual.net...
> Steve wrote:
>
>> I'm hoping this is going to be a simple adjustment to someone who knows
>> what
>> they're doing :)
>
>
> You could try to GROUP BY on name_list.id.
>
>
> --
>
> //Aho