I have this data:
| parent_id | comment_id | comment_level |
|---|---|---|
| NULL | 0xB2 | 1 |
| NULL | 0xB6 | 1 |
| NULL | 0xBA | 1 |
| NULL | 0xBE | 1 |
| NULL | 0xC110 | 1 |
| NULL | 0xC130 | 1 |
| 123 | 0xC13580 | 2 |
| 456 | 0xC135AC | 3 |
| 123 | 0xC13680 | 2 |
I want the result in such a way that rows where comment_level=1 should be in descending order by comment_id and other rows(i.e. where comment_level!=1) should be in ascending order by comment_id but the order of comment level greater than 1 should be inserted according to to order of comment level 1 (what I mean is that rows with comment_level=1 should remain in descending order and then rows with comment_level!=1 should be inserted in increasing order but it should be inserted following rows where comment_id is less than it)
Result should look like this
NULL 0xC130 1 123 0xC13580 2 456 0xC135AC 3 123 0xC13680 2 NULL 0xC110 1 NULL 0xBE 1 NULL 0xBA 1 NULL 0xB6 1 NULL 0xB2 1
Note the bold rows in above sort by comment_id in ascending order, but they come after their "main" row (with comment_level = 1), where these main rows sort DESC by comment_id.
I tried creating 2 tables for different comment level and used sorting for union but it didn't work out because 2 different order by doesn't work maybe I tried from this Using different order by with union but it gave me an error and after all even if this worked it still might not have given me the whole answer.