For example:
id 1,2,3,4,5,6,7,8,9,10
I want to show first id = 7and after 10,9,8,6,5,4,3,2,1. How to write this code using php? Please help me(Sorry for bad English)
id = 7
10,9,8,6,5,4,3,2,1
(Sorry for bad English)
MySQL is convenient when logical expressions are treated as integers, and for "1" - "1" and "0" - false. A quick way to write this:
order by (id = 7) desc, id desc
In other databases you need to use caseor similar logic.
case
You can order a specific expression case:
SELECT * FROM mytable ORDER BY CASE id WHEN 7 THEN 0 ELSE 1 END ASC, id DESC
Source: https://habr.com/ru/post/1620872/More articles:How to avoid parsing error on angularjs when using mathjax to view html from server - javascripthow to remove the last line li :: after for the first line in a specific width div - htmlJavascript complex Single-layer if statements - javascriptsocket connection closed before receiving a response to establish a connection - node.jsBeautifulSoup: how to ignore false end tags - pythonThe right table with columns with multiple series - google-visualizationSegmentation error while calling C function with Python C API - cHow to write unit test to get nsnotification asynchrony? - iosCall Python function from Fortran / C - cRemoving wrapped lines - pythonAll Articles