Limit a Left Join on the first table

前端 未结 2 1013
陌清茗
陌清茗 2021-02-14 06:51

I have two tables: gems and gemdetail that are left joined. I am trying to limit the LEFT JOIN to 10 records in the gems table. There are 2 other tables joined (gemreply and use

2条回答
  •  萌比男神i
    2021-02-14 07:41

    Something like that

       SELECT * FROM A
          INNER JOIN ( SELECT * FROM A WHERE A.FIELD1='X' ORDER BY A.FIELD2 LIMIT 10) X
                 ON (A.KEYFIELD=X.KEYFIELD)
          LEFT JOIN B ON (A.FIELD = B.FIELD)
          LEFT JOIN C ON (A.FIELD = C.FIELD)
    

提交回复
热议问题