X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8DA05D1ECD0 for ; Sat, 3 Apr 2004 15:09:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59675-08 for ; Sat, 3 Apr 2004 11:09:21 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id E7FEDD1ECF9 for ; Sat, 3 Apr 2004 11:09:07 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i33F9ESx027975 for ; Sat, 3 Apr 2004 15:09:14 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i33F8V7Z027925 for pgsql-sql@postgresql.org; Sat, 3 Apr 2004 15:08:31 GMT From: Gregor Rot User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.sql Subject: Re: order of results References: <20040326215303.GC21119@wolff.to> In-Reply-To: <20040326215303.GC21119@wolff.to> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 29 Message-ID: Date: Sat, 03 Apr 2004 17:08:34 +0200 X-Complaints-To: abuse@siol.net Organization: Slovenija OnLine - SiOL To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/21 X-Sequence-Number: 17396 Bruno Wolff III wrote: > On Thu, Mar 25, 2004 at 14:23:00 +0100, > Gregor Rot wrote: > >>Hi, >> >>i have a table called "people" (name:varchar, lastname:varchar). >> >>i do a select on it: >> >>select * from people where name like '%n1%' or lastname like '%l1%'. >> >>i would like the results in this order: >> >>first the results that satisfy only the (name like '%n1%') condition, >>then the ones that satisfy only the (lastname like '%l1%') condition and >>last the results that satisfy both conditions. >> >>Is this possible in only one SQL? >>(note that the search conditions n1 and l1 differ from search to search. > > > Yes. You can order by true/false results from conditions to get the > results in the desired order. Thank you - sorry, but how do you do that? Tnx, Gregor