y endorse content contained within this
transmission. > From: [EMAIL PROTECTED]> To: mysql@lists.mysql.com> Subject:
Result ordering> Date: Sun, 30 Nov 2008 23:33:47 +0100> > > Hi, I'm retrieving
the name of some records where either one of two > criteria are sati
On Nov 30, 2008, at 11:42 PM, Andy Shellam wrote:
Hi Morten,
I think this is valid in MySQL (it certainly is for SQL Server) but
you can use a CASE statement directly in the ORDER BY clause. Try
something like this:
SELECT name
FROM foo
WHERE bar = 34
OR baz > 100
ORDER BY CASE ba
Hi Morten,
I think this is valid in MySQL (it certainly is for SQL Server) but you
can use a CASE statement directly in the ORDER BY clause. Try something
like this:
SELECT name
FROM foo
WHERE bar = 34
OR baz > 100
ORDER BY CASE bar WHEN 34 THEN 0 ELSE 1 END ASC, baz DESC
LIMIT 5;
Re
Hi, I'm retrieving the name of some records where either one of two
criteria are satisfied:
SELECT name
FROM foo
WHERE bar = 34
OR baz > 100
ORDER BY baz DESC
LIMIT 5;
I would like to sort that result set, such that the records matching
bar = 34 occur before records with baz > 100.