[thelist] selecting above and below ranges in a SQL query [long]
Chris Blessing
webguy at mail.rit.edu
Mon Aug 26 13:21:01 CDT 2002
FYI -- the LIMIT clause comes after the ORDER BY clause, and after the
optional DESC keyword. My apologies. Thanks to everyone else who actually
wrote their responses correctly. :D
Chris Blessing
webguy at mail.rit.edu
http://www.330i.net
> mysql> select id, erlang_no from ErlangTest
> -> where erlang_no < '1.5'
> -> limit 3
> -> order by erlang_no
> -> desc;
>
> mysql> select id, erlang_no from ErlangTest
> -> where erlang_no > '1.5'
> -> limit 3
> -> order by erlang_no;
>
> mysql> (select id, erlang_no from ErlangTest
> -> where erlang_no < '1.5'
> -> limit 3
> -> order by erlang_no
> -> desc)
> -> UNION
> -> select id, erlang_no from ErlangTest
> -> where erlang_no = '1.5'
> -> UNION
> -> (select id, erlang_no from ErlangTest
> -> where erlang_no > '1.5'
> -> limit 3
> -> order by erlang_no)
More information about the thelist
mailing list