Here's the tail end of some code I have in place. DB_TABLE."users.ID ".$addon." ORDER BY ".DB_TABLE."tickets.`status` ASC;"); PHP: I would like it to ORDER BY the status first and then by ID, however, the following is not working for me. DB_TABLE."users.ID ".$addon." ORDER BY ".DB_TABLE."tickets.`status` ASC;", "tickets.`ID` DESC;"); PHP: I also tried: DB_TABLE."users.ID ".$addon." ORDER BY ".DB_TABLE."tickets.`status` ASC, tickets.`ID` DESC;"); PHP: What is it that I am doing wrong here? Any help is appreciated. Thanks.
You can use multiple column in order by clause. Order by coloum1 ASC, colum2 ASC & so on.. So I think your 2nd statement is correct. I think it will work perfectly.......
Hi, ashishhbti has replied your question but here is once again ......... "ORDER BY ".DB_TABLE."tickets.`status` ASC, ".DB_TABLE."tickets.ID DESC;") PHP: Regards ps: seems you forgot to concatenate DB_TABLE for the second order rule
When you're building anything but the simplest sql queries in php it's a good habit during the development stage to echo your sql statements as you build them. This way you can see the query the way it would be run. You can copy the output from the echo and run it directly on your mysql server using your favourite sql query tool. If the query generates the results you're looking for you're good to go. When you start concatenating a combination of text and variables it's easy to miss a quote or comma. By echoing the sql it's much easier to see the actual sql. And don't forget to remove the echo before going live.