Received: from openmail.kick.com (adsl-63-205-173-34.dsl.snfc21.pacbell.net [63.205.173.34]) by hub.org (8.10.1/8.10.1) with ESMTP id e6K0e5h95402 for ; Wed, 19 Jul 2000 20:40:05 -0400 (EDT) Received: from planetblargh (adsl-63-205-173-36.dsl.snfc21.pacbell.net [63.205.173.36]) by openmail.kick.com (8.9.3/8.9.3) with SMTP id RAA05514; Wed, 19 Jul 2000 17:40:00 -0700 Message-ID: <010b01bff1e2$cfe02760$0c64010a@kick.com> From: "Stephan Szabo" To: "Bernie Huang" Cc: References: <39764717.7B5EB600@ec.gc.ca> Subject: Re: Order by in Select Date: Wed, 19 Jul 2000 17:38:23 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Archive-Number: 200007/186 > What can I add to the above sql statement so that is fetches the > specified id first in a sorted list? > > eg: if $specified_id=5; > I want: 5,5,5,1,2,3,3,4,4,4,6,6,7 > > I could have done it in two different sql statements where one fetches > specified_id and the other fetches and sorts others, but I want to be > able to do it in one sql statement to reduce time. Umm, maybe something like: select id from table order by case when id=$specified_id then else id end