Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Date: Sat, 03 Aug 2013 12:53:00 +0200 From: Luuk User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 Newsgroups: comp.lang.php,alt.php Subject: Re: sql order but move some rows bottom References: <1qthmi1tu68bo$.9vs28kns3wda.dlg@40tude.net> In-Reply-To: <1qthmi1tu68bo$.9vs28kns3wda.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 50 NNTP-Posting-Host: 2001:980:9089:1:b900:c8e4:3423:5055 X-Trace: 1375527301 news.xs4all.nl 15970 [2001:980:9089:1:b900:c8e4:3423:5055]:38644 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.php:10356 On 03-08-2013 12:44, nawfer wrote: > I would like to order a list; sorted by column 1, > but when the elements have the value 100, > move them at the end of the list > > A) > if I have 2 columns > a 2 > b 1 > c 100 > d 1 > a 100 > b 1 > c 2 > d 1 > > B) > to sort by column 1 > a 2 > a 100 > b 1 > b 1 > c 2 > c 100 > d 1 > d 1 > > C) > but make sure that when I 100 the row is moved under > a 2 > b 1 > b 1 > c 2 > d 1 > d 1 > a 100 > c 100 > > how can solve both with sql and with php? I was interested in both > solutions although I prefer to understand first how can do with sql; > > the sql after fill the php array; > > if I use ORDER BY column1 ASC, (column2 = 100) ASC > in reality does how in B) > ORDER BY (column2 = 100) ASC, column1 ASC, column2 ASC ?