tags:

views:

26

answers:

1

Hi,

I have a table with SIGNUPS to different events. This table has some simple columns like ID, IDUSER, IDEVENT and DATE. Each event is characterized my a maximum amount of people who can attend, so the table EVENTS has a column called let's say PLACES.

What I want to obtain for a given event is the list of the first "PLACES" signups to that event, that is the people who registered on time. The others will be marked on a Waiting List.

The behaviour should be something like "select the first PLACES signups to event X"

I tried to use LIMIT PLACES but it doesnt seem to be a valid syntax.

Any hint?

+1  A: 

There is a known bug in MySQL regarding the use of variables with the LIMIT clause.

That article also describes a workaround posted by Kian Ryan:

DROP PROCEDURE IF EXISTS get_product_range $$
CREATE PROCEDURE get_product_range (
IN _START INTEGER,
IN _LIMIT INTEGER
)
BEGIN
PREPARE STMT FROM
" SELECT *
FROM products LIMIT ?,? ";
SET @START = _START;
SET @LIMIT = _LIMIT;
EXECUTE STMT USING @START, @LIMIT; /* Known bug in mySQL5 - exists as feature req. */
END $$

hth

richaux