HOW TO ORDER BY with certain results first similar to sponsors links idea
Please, advise on proper query:
I am looking to select results from the table, but I want to show all results by particular ID first, then everyone else, sort of like you would see "sponsored links" first.
10 users with incremental IDs from 1 to 10.
Each has multiple listings of widgets in the widgets tables. Each widget is associated with user ID.
I want to select all widgets from the widgets table based on whatever condition I have, but I want to display results for particular user with ID=6 first. so results would be something like this:
Create a temp table with all the columns you wish to select, then SELECT into the table those records with the ID you want, then SELECT into the table all the other records (without the ID) sorted by ID, then SELECT from the temp table without specifying any kind of ORDER BY clause.
Not tested, but it seems correct. The temp table (if properly created) will be nulled when the query is over.