I have a code which selects 10 of the users who have "earned" money ordering by the price desc. I have been using this query
SELECT products.seller,
SUM(products.price * (1 - reseller.fee / 100)),
COUNT(*)
FROM products
INNER JOIN reseller ON reseller.username = products.seller
WHERE (products.seller!= 'MYSITE')
AND products.sold=1
AND products.sellerpaid=0
AND products.username != 'None'
GROUP BY products.seller
ORDER BY SUM(products.price * (1 - reseller.fee / 100)) DESC
LIMIT 10
By this i get:
uploaded_by SUM() COUNT()
username 10.00 2
username1 11.00 3
....
Which works absolutely fine, but now i have another table, products1 and that contains something more thats why i cannot merge them, so I want to get the same results as in the first one but fetching the price of all products from this table as well I have tried LEFT JOIN, RIGHT JOIN, and many others but still cant do it correctly.
Please do not tell me to read more about joins cuz i already have, just cant do it, if you can come up with a solutions then post it if possible.
Also if there is anything that you do not understand, please comment so I can give further explanations.
Thank you.
Aucun commentaire:
Enregistrer un commentaire