> -----Original Message-----
> From: Chris [mailto:[EMAIL PROTECTED] 
> Sent: maandag 14 augustus 2006 3:55
> To: Mark
> Cc: mysql@lists.mysql.com
> Subject: Re: Random SELECT on subset
> 

> > In Perl, I'm trying to get 4 random entries from a subset 
> > "WHERE processed
> > = '1'" and "columnId" is unique. Like so:
> > 
> > $sth = $dbh->prepare ("SELECT columnId FROM queue WHERE
> > columnId >= (SELECT FLOOR(MAX(columnId) * RAND()) FROM
> > queue) IN 
> (SELECT columnId FROM
> > queue WHERE processed = '1') ORDER BY columnId LIMIT 4");
> 
> I'm not even sure what you're trying to get here!
> 
> Could you provide some sample data (5 rows) and what you want 
> the query to return?

Well, there are a great many colums in the real rows, but say they are like
this:

columnID, picturename, processed, ....

1         name1        1
2         name2        0
3         name3        1
4         name4        1
5         name5        1
6         name6        0
7         name7        1

Then I want to select 4 random columnIDs, but only from the subset
WHERE processed = '1' (so, from the group 1,3,4,5,7).

Thanks. I appreciate your help.

- Mark


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to