I have 2 tables
1) "products" with fields (productid PK, name, description, price)
2) "sales" with fields (salesid PK, salestime, productid, customername, customeremail, status)
I need to display data in table format as
SalesID Product Name Amount Customer Name Customer Address Payment Status
For this, I am using following query
SELECT s.salesid, p.name, p.price, s.customername, s.customeremail, s.status
FROM sales s
LEFT JOIN products p ON s.productid = p.productid
ORDER BY salestime DESC
LIMIT 0, 15
Is there any way I can still optimize this query to run faster?
Do you have the appropriate indexes on the tables?
Have a look at CREATE INDEX Syntax and How MySQL Uses Indexes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With