Ulf Harnhammar writes:
> This is a suggestion for a small addition to MySQL's syntax which I'm
> proposing, unless someone is kind enough to show me that there already is
> equivalent functionality somewhere else in MySQL.
>
> See, what I want to do is select a few random rows among those that
> normally would be returned. I don't want to select all matching ID's in
> one select, retrieve them to my script, and then construct another SELECT,
> because this seems to be slow. I don't want to use lots of "SELECT
> something FROM sometable LIMIT number,1" statements either, because this
> seems to be slow too.
>
> I propose this additional syntax to Monty and the guys:
> SELECT something FROM sometable WHERE somevar=somevalue
> LIMIT number1,1,number2,1,number3,1,..
> which should return the rows numbered "number1", "number2", "number3" etc
> from the rows that normally would be returned. This way, I could first use
> a "SELECT COUNT(*) FROM sometable WHERE somevar=somevalue" statement, and
> then issue another statement of the kind that I propose, to get a few
> random rows.
>
> Perhaps there already is some way to do this efficiently. In that case,
> please enlighten me.
>
> Regards, Ulf Härnhammar
>
> PS: Talking about Monty, is he by any chance the same Monty who was in a
> team called Monty & Kaj and wrote a PacMan clone called Blipp for the
> ABC80 computer decades ago? Man, that game was cool! ;)
>
> ________________________________________
> Ulf Härnhammar
> System Developer
>
> ST-Registry
> St Eriksgatan 117, E2
> SE-113 43 Stockholm
> SWEDEN (GMT+1)
>
> Telephone: +46 (0)8-545 476 04
> Facsimile: +46 (0)8-32 63 33
>
> E-mail: ulf@stripped
> Web: http://www.nic.st/
Hi!
Using RAND() function with LIMIT would obtain the same result.
Regarding PS:
I did not know about Blipp, but both Monty and Kaj are in MySQL AB !!
--
Regards,
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <sinisa@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com