MySQL Order By alternate values
Im having trouble in MySQL query Order By.
First I have a table(tbl_records) that contains 10000+ records. This table
has a primary key called rec_id and a foreign key rec_f_id.
rec_f_id has only two kinds of value (555, 666).
Now my problem is how can I gather the records on the table that orders in
alternate value of rec_f_id.
Eg
SELECT * FROM tbl_records ORDER BY FIELD(rec_f_id, 555, 666) LIMIT 100;
The above query only returns record with rec_f_id = 555. What I want to
have is
| rec_id | rec_f_id |
|1 |555 |
|2 |666 |
|3 |555 |
|4 |666 |
|5 |555 |
|6 |666 |
|7 |555 |
|8 |666 |
|9 |555 |
...
Thanks!
No comments:
Post a Comment