mysql - How to limit results of a LEFT JOIN -
Take the case of two tables: tbl_product
and tbl_transaction
.
I need to display a web page in which 10 products and each product, the last 5 transactions are being shown. So far, no LEFT JOIN
query is not working and will be working on the Sbkwarry below if mysql tx.product_id = ta.product_id
portion ( Unknown In column 'ta.product_id' where 'clause': [error: 1054] ).
includes SELECT ta.product_id, ta.product_name, tb.transaction_date FROM tbl_product ta LEFT in (SELECT tx.transaction_date FROM tbl_transaction tx WHERE tx.product_id = ta.product_id LIMIT 5) TB LIMIT 10
Do I want a method to get the list Inquiries in a loop without multiple usage ? In
Edit:
This is what I need from MySQL:
SELECT ta.product_id, ta.product_name, tb .transaction_date ... tbl_product Join tots tbl_transaction tb oN (tb.product_id = ta.product_id LIMIT 5) LIMIT 10
of course it's illegal, but I really wanted that it not!
This is where ranking work will be very useful. Unfortunately, MySQL does not support them yet. Instead, you're involved in these kind of can try something
select as tb.transaction_date Left ta ta.product_id, ta.product_name, tbl_product (tx1.product_id, tx1. on transaction_id, tx1.transaction_date, (select count (*) where as select tx2 from tbl_transaction tx2.product_id = tx1.product_id and tx2.transaction_id & LT; tx1.transaction_id) tb.product_id = ta.product_id and TB [ rank] as tbl_transaction TX1) as [rank] as TB & lt ;. = 4 threshold 10
Comments
Post a Comment