反向SELECT查询结果

时间:2019-01-31 12:00:16

标签: postgresql sql-order-by recursive-cte

我有一个递归查询,它从层次模型返回一些行。 种类:

files_array := ARRAY
   (WITH RECURSIVE files_to_parent AS (
          SELECT FileID, Name, ParentID
          FROM File
          WHERE FileID = file_id
       UNION ALL
          SELECT F.FileID, F.Name, F.ParentID
          FROM files_to_parent ftp, File F
          WHERE F.FileID = FTP.ParentID
    )
    SELECT Name FROM files_to_parent);

如何反转SELECT查询的结果?

PS:我无法按ID排序,父母的ID可能比孩子的ID大或小。

1 个答案:

答案 0 :(得分:1)

您必须添加一个显式String bootstrap_Server = "x.x.x.x:port" private static KafkaProducer<String, String> producer = null; Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrap_Server); props.put(ProducerConfig.CLIENT_ID_CONFIG, "KafkaExampleProducer"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); props.put(ProducerConfig.ACKS_CONFIG, "all"); props.put(ProducerConfig.RETRIES_CONFIG, 0); props.put(ProducerConfig.BATCH_SIZE_CONFIG, 16384); props.put(ProducerConfig.LINGER_MS_CONFIG, 1); producer = new KafkaProducer<String, String>(props); kafkaInTopicName = "TestTopic"; Key = "123123"; value = "{ValidJsonData}"; producer.send(new ProducerRecord<String, String>(kafkaInTopicName, key, value)).get(); ``` 子句才能获得特定顺序:

ORDER BY