I am trying to run a ORDER BY query but I want the output to be ordered according to a custom scheme. In SQL this is often done with a case system, but depending on the DB there are also other implementations. How would I achieve the sorting explained below with GridDB?
Lets assume my GridDB lists all the animals that are in a zoo and how many of each live there, I would like all the animals of which there are 4 or more, by size, smallest first (mouse), largest last (elephant).
Things I tried:
$query = $col->query("SELECT * WHERE count >= 4 ORDER BY CASE
WHEN 'mouse' THEN 1
WHEN 'cat' THEN 2
WHEN 'dog' THEN 3
WHEN 'elephant' THEN 4
ELSE 5
END");
$query = $col->query("SELECT * WHERE count >= 4 ORDER BY FIND_IN_SET(animal, 'mouse, cat, dog, elephant')";
In either case one receives an error that the input is not valid syntax.