I have the following code which gets items to present to a user:
SELECT * FROM main_cue WHERE group_id IN (1,2,3,4) GROUP BY group_id;
>>> 1,2,3,4
However, I want to provide a specific ordering to this, such that (1) I have a list of items to push to the end of the stack In the exact ordering I specify and (2) the items that are not in the list will be ordered by id ASC. For example:
items_to_push_to_end_of_stack_in_this_exact_order = [3,2]
The new ordering would then be:
>>> [1,4,3,2]
1) 1 # first item by ID asc, not in `items_to_push_to_end_of_stack_in_this_exact_order`
2) 4 # second item by ID asc, not in `items_to_push_to_end_of_stack_in_this_exact_order`
3) 3 # items_to_push_to_end_of_stack_in_this_exact_order
4) 2 # items_to_push_to_end_of_stack_in_this_exact_order
How would I do this in mysql?