shadedecho
Programmer
(This sounds very simple, and yes there would be other programatic ways to do it, but I'm searching for a SQL only answer for some specific reasons. Also, I really feel like it needs to be in one (maybe two) SQL statements, not one for each.)
What I would like is to run a generic SELECT statement (not on a specific table) that returned a result set which had one row for each value in the range from a specified minimum to maximum. For instance, return a result set that gave all the numbers from 7 to 311 (would have 305 rows: 7,8,9...310,311). I am running mysql 3.23.
I have tried several variations on the following:
SELECT @a := 7, @b := 311, @c WHERE ((@c) BETWEEN (@a) AND (@b))
SELECT COUNT(*) as 'c' WHERE (c BETWEEN 7 AND 311)
SELECT @c := COUNT(*) WHERE (@c) BETWEEN 7 AND 311)
SELECT @c WHERE @c IN (7,8,9,10,11,12)
SELECT @myval WHERE BETWEEN(@myval,7,311)
I've also tried implementing some sort of sequentially incrementing variable, like this:
SELECT @c := @c + 1 LIMIT 7,311
HELP! Nothing seems to work, I always get a syntax error returned to me of some form or another. Does anyone know how to do this in a SQL statement?
What I would like is to run a generic SELECT statement (not on a specific table) that returned a result set which had one row for each value in the range from a specified minimum to maximum. For instance, return a result set that gave all the numbers from 7 to 311 (would have 305 rows: 7,8,9...310,311). I am running mysql 3.23.
I have tried several variations on the following:
SELECT @a := 7, @b := 311, @c WHERE ((@c) BETWEEN (@a) AND (@b))
SELECT COUNT(*) as 'c' WHERE (c BETWEEN 7 AND 311)
SELECT @c := COUNT(*) WHERE (@c) BETWEEN 7 AND 311)
SELECT @c WHERE @c IN (7,8,9,10,11,12)
SELECT @myval WHERE BETWEEN(@myval,7,311)
I've also tried implementing some sort of sequentially incrementing variable, like this:
SELECT @c := @c + 1 LIMIT 7,311
HELP! Nothing seems to work, I always get a syntax error returned to me of some form or another. Does anyone know how to do this in a SQL statement?