这是排名函数非常有用的地方。不幸的是,MySQL尚不支持它们。相反,您可以尝试类似以下的方法。
Select ta.product_id, ta.product_name , tb.transaction_dateFrom tbl_product As ta Left Join ( Select tx1.product_id, tx1.transaction_id, tx1.transaction_date , (Select Count(*) From tbl_transaction As tx2 Where tx2.product_id = tx1.product_id And tx2.transaction_id < tx1.transaction_id) As [Rank] From tbl_transaction As tx1 ) as tb On tb.product_id = ta.product_id And tb.[rank] <= 4Limit 10



