qiuweilu commented on issue #13851:
URL: 
https://github.com/apache/shardingsphere/issues/13851#issuecomment-984350899


   SELECT *
   FROM (SELECT cmnt_tab.*,
                count(cmnt_tab.cmnt_id)  vote_num,
                vote_bind_tab.bind_fkid  vote_bind,
                vote_bind_tab.vote_label vote_label
         FROM (
               SELECT base_cmnt.*
               FROM part_cmnt base_cmnt
               WHERE base_cmnt.part_fkid = ?  #-- 1 Sub table foreign key
               ORDER BY base_cmnt.cmnt_id DESC
               LIMIT 2000) 
               cmnt_tab LEFT JOIN part_vote vote_bind_tab
                   ON vote_bind_tab.bind_fkid = cmnt_tab.cmnt_id 
                   AND vote_bind_tab.part_fkid = ? #-- 2 Sub table foreign key
               GROUP BY cmnt_tab.cmnt_id
       ) out_cmnt LEFT JOIN part_vote_1 vote_user_tab
       ON vote_user_tab.bind_fkid = out_cmnt.cmnt_id 
       AND vote_user_tab.part_fkid = ? #-- 3 Sub table foreign key
   GROUP BY cmnt_id
   LIMIT ?
   
   question
   #-- 1 Sub table foreign key,it works ok
   #-- 2 Sub table foreign key,it doesn't work  (left join)
   #-- 3 Sub table foreign key,it doesn't work (left join)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to