tags:

views:

46

answers:

1

Hi guys, I've got this table

CREATE TABLE `subevents` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(150) DEFAULT NULL,
  `content` text,
  `class` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM

Each row can have a different value in the 'class' field.

I'd like to select any number of rows, ordered randomly, as long as the sum of the values in the 'class' field is equal to 100.

How could I accomplish it directly in the MySQL query without doing it later in PHP?

Thanks everybody!

A: 

I don't think this is possible with only SQL...the only thing which comes to my mind is to redo a the sql query as long the sum isn't 100

But I have no clue how to select a random number of rows at once.

poeschlorn