关于mysql查询中的orderby的困惑

时间:2017-06-11 08:00:47

标签: mysql mysqli sql-order-by

以下是mysql查询:

SELECT * FROM `is_product_info` ORDER BY (select distinct product_id from is_product_images where is_product_images.product_id = is_product_info.id) asc

我不知道订单如何与子查询一起使用。

我遇到了在wordpress插件中使用子查询订购的查询。这对我来说是新的,所以我在问别人是否知道这件事。以下是这样的例子:

SELECT wp22_posts.* 
  FROM wp22_posts 
  LEFT 
  JOIN wp22_term_relationships 
    ON wp22_posts.ID = wp22_term_relationships.object_id
 WHERE 1=1 
   AND wp22_posts.ID IN(260,412,413,414,415,469,474,483
                       ,485,487,488,515,516,563,568‌​,569
                       ,584,592,593,596‌​,599,601,604,610
                       ,612‌​,672,675,678,681,690‌​,860,861,862,863)
 GROUP 
    BY wp22_posts.ID 
 ORDER 
    BY (SELECT distinct meta_value from wp22_postmeta where'meta_key' LIKE 'price') ASC 
 LIMIT 0, 10

是否有人描述此查询?

1 个答案:

答案 0 :(得分:0)

要回答你的问题,ORDER BY子句什么都不做(除了可能阻止查询工作)。