My table looks like this:
a | b
In my query, I want to change the order by clause depending on the type of column.
So something like
get_data($order_by_column) { .... ORDER BY CASE WHEN is_numeric($order_by_column) THEN $order_by_column ELSE CHAR_LENGTH($order_by_column) END }
I checked, and it is quite difficult to determine the type of the column dynamically, as in the above query. What would be the alternative (or alternatives) to achieve this?
source share