I have some simple query:
SELECT * FROM table
You all know the result:
|id| foo | bar |
-------------------------
|1 | aaa | 123 |
|2 | bbb | 234 |
|3 | ccc | 345 |
|4 | ddd | 456 |
but, what I want to do show from record number 3? I know I can do it with SELECT * FROM table where id=3, but I need to set the record I choose is in first rank, let say I choose id=3 so the result as follow:
|id| foo | bar |
-------------------------
|3 | ccc | 345 |
|4 | ddd | 456 |
|1 | aaa | 123 |
|2 | bbb | 234 |
or
|id| foo | bar |
-------------------------
|3 | ccc | 345 |
|1 | aaa | 123 |
|2 | bbb | 234 |
|4 | ddd | 456 |
is this possible?
This way you get
id = 3first:Order by
idadditionally if you want the rest ordered, too.Explanation:
The expression evaluates to boolean.
FALSE(= 0 in mysql) sorts beforeTRUE(= 1 in mysql), so we order descending.It also automatically covers the case of
idbeingNULL. I quote the manual again here: