Imagine this, you have a class and enum like:

and you want to sort users by their status, but users with error first. How to do that? Continue reading

Well, first rule – you should not do this. But if there is good reason, consider using such query for searching in index-based arrays:

In case you have assoc array serialized you can use:

Of course it won’t be very fast but in small tables should be enough