SQL Table:
-----------------------------------------
| ID | COLOR | DATE |
|-----|-----------|---------------------|
| 1 | ORANGE | 2011-11-03 01:14:00 |
| 2 | YELLOW | 2011-11-03 01:13:00 |
| 3 | GREEN | 2011-11-03 01:16:00 |
| 4 | BLUE | 2011-11-03 01:16:00 |
| 5 | PINK | 2011-11-03 01:12:00 |
-----------------------------------------
The following query gives me the results ordered by date:
SELECT *
FROM `table`
ORDER BY `date` DESC
LIMIT 0, 4
-----------------------------------------
| RESULT: |
|---------------------------------------|
| 3 | GREEN | 2011-11-03 01:16:00 |
| 4 | BLUE | 2011-11-03 01:16:00 |
| 1 | ORANGE | 2011-11-03 01:14:00 |
| 2 | YELLOW | 2011-11-03 01:13:00 |
-----------------------------------------
But what if I wanted to order it by date and also start from a specific ‘color’?
SELECT *
FROM `table`
ORDER BY `date` DESC
LIMIT 0, 4
START WHERE `color`='blue'
-----------------------------------------
| RESULT I WANT: |
|---------------------------------------|
| 4 | BLUE | 2011-11-03 01:16:00 |
| 1 | ORANGE | 2011-11-03 01:14:00 |
| 2 | YELLOW | 2011-11-03 01:13:00 |
| 5 | PINK | 2011-11-03 01:12:00 |
-----------------------------------------
^What is the correct syntax to get this result?
Updated:
Second update to meet newly discovered criteria.