Let's say I have a table that looks like this:
As you can see, line with identifier 6 is the answer to line with identifier 3. I would like to order a result set so that it appears between lines 3 and 7. How to do this? Fulfillment: select * from comments_comment order by updated_at, response_to_idgets exactly what you can see in the image.
select * from comments_comment order by updated_at, response_to_id
ORDER BY COALESCE(response_to_id, id), id
The logic of your order is that you want the parent records and their children to appear together and the parent to appear on top of the group.
ORDER BY , , response_to_id id , response_to_id null. id.
ORDER BY
response_to_id
id
Source: https://habr.com/ru/post/1649988/More articles:Не удается подключиться к 127.0.0.1 (localhost) порталу устройств в UWP с помощью HttpClient или иначе (только для Windows 10 Mobile RS1) - c#RequireJS JS concatenation but not minimization - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1649985/c-httpwebrequest-not-sending-default-credentials-to-proxy-server&usg=ALkJrhjRrudpcZ9uq25i7Fb7Fr8ciCLVPgHow to configure SpringBoot log setting in application.yml? - spring-bootAttach an array of objects by javascript property - javascriptShould I use .gitignore for Laravel? - gitElasticSearch introduces read-only mode, node cannot be changed - elasticsearchGetting duplicate fingerprint errors when updating SHA-1 fingerprint for oAuth2 client ID for Android - androidAjax JSON data conflicts and lightbox - jsonLocal encryption of data on the Internet or blocking access - local-storageAll Articles