在HAVING子句中使用SELECT语句时,如何省略该列?
技术问答
427 人阅读
|
0 人回复
|
2023-09-12
|
这是我的查询:
% x7 ], x! B1 |7 [3 [SELECT e.id,(SELECT MIN(u.id) id FROM (SELECT MIN(id) id FROM events WHERE author_id = 322 GROUP BY type,post_id,table_code,comment_id,context ORDER BY MIN(id) desc LIMIT 15) as u as indicator_idFROM events eWHERE author_id = 32HAVING e.id >= indicator_idORDER BY id DESC它还可以正常工作,并返回两列:id和indicator_id。, u9 U/ T( h: o) {
我只需要得到id。我该怎么省略呢?indicator_id?如你所见,我需要使用它indicator_idintoHAVING所以我不能省略整个子查询。我只需要把它移动到SELECT声明以外的其他位置。语法是什么?! a- F8 `; @2 A* y% B7 V
& w$ Y, k/ N# y& |/ r. _% j2 Q 解决方案: |
|
|
|
|
|