I have a query for search results for posts. And I want the entries written by me (userId = 27) to be first in the query results, and the rest ordered by timestamp. Can someone give me a query for this in mysql?
select * from posts order by if (userid=27, -1, any_timestamp_include_zero);
best to use your full table schema schema
How about something like:
select * from post order by case when userid = 25 then '0001-01-01 00:00:00' else my_timestamp end
(formatting part "0001-01-01" for MySql)
Something simple:
SELECT * FROM POST WHERE userId = 25 UNION SELECT * FROM POST WHERE userId <> 25 ORDER BY TIMESTAMP_FIELD
May work for your needs?
Source: https://habr.com/ru/post/892746/More articles:C # Entity Framework using only one ObjectContext for HttpContext - c #Bind multiple lines of text to label - c #CakePHP: Running a shell job from a controller - shellHow to Change DateTimeFormatInfo.CurrentInfo Collection of AcronymDayNames - c #Order AA before A - databaseJquery function setInterval - functionDelay when using full-text search in SQL Server - sqlWhy sscanf does not work properly with the bool type - c ++Using your Google account as a login ... what's next? - androidPossible location-based installation in WPF? - .netAll Articles