OsakaWebbie
Programmer
My first time using ORDER BY FIELD(), and it seems pretty simple, but it's not working for me. The value of FIELD() is correct, but in the ORDER BY location, it seems to have no effect on sorting. After simplifying to try to find the problem, here is my diagnostic query:
The results come in like this (PersonID is an autoincrement integer field that is the primary key):
So FIELD() seems to be working, but why isn't the result set getting sorted by it?
Code:
SELECT PersonID, FIELD(PersonID,2957,5,3883,3292,713,1248,2971,3538) FROM person WHERE PersonID IN (2957,5,3883,3292,713,1248,2971,3538) ORDER BY FIELD(PersonID,2957,5,3883,3292,713,1248,2971,3538)
Code:
5 2
713 5
1248 6
2957 1
2971 7
3292 4
3538 8
3883 3