Currently my query looks like this:
SELECT name FROM items
WHERE something = "foo"
AND name > (SELECT name FROM items WHERE name = ?)
GROUP BY name
ORDER BY name ASC
LIMIT 1
(found it here)
It seems to work, but if I change >
to <
(to get previous record), I get no results, even though I know there are :(
What am I doing wrong?
name
is a TEXT field, but I'd like to be able to sort by any other field, so I want my query to work with any type.