chick3n Posted July 31, 2008 Share Posted July 31, 2008 Is it possible to re-make a query so that it would order the results by name alphabetically, except 1 result that i want to be returned first, and that 1 result is dynamic so it cannot be hard coded. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 31, 2008 Share Posted July 31, 2008 Not that I know of but you could use and IF statement with CONCAT and add characters to the front of a string to force it to be first in the sorting example select ColID, IF(ColID = CRITERIA TO BE #1,CONCAT('AAAAAAAAAAAA_',Colname),Colname) as SortField from `table1` ORDER BY SortField Then using php or whatever strip the AAAAAAAAAAA_ from it if its the first row in the while($row = fetch) Quote Link to comment Share on other sites More sharing options...
fenway Posted August 5, 2008 Share Posted August 5, 2008 You can also do this in the ORDER BY clause directly... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.