So, short explained: I wanna get all records from the table games_records ordered by the highest furni value (pricelist_furnis_tradevalue.value) multiplied by the records amount (= games_records.amount). The furni value is in pricelist_furnis_tradevalue.
Now… The pricelist_furnis_tradevalue has multiple entries for some furnis. I wanna get only the newest entry, therefore it should be ordered by pricelist_furnis_tradevalue.time.
But this query below returns all entries from pricelist_furnis_tradevalue for each furni/record.
SELECT *
FROM games_records
JOIN pricelist_furnis_tradevalue
ON games_records.furni = pricelist_furnis_tradevalue.furni
ORDER BY (pricelist_furnis_tradevalue.value*games_records.amount) DESC
Here are the structures of the 2 needed tables
games_records
id user furni amount time
1 2 4 40 1338052926
2 4 30 90 1338054046
pricelist_furnis_tradevalue
id furni value time
1 2 20 1334065379
2 2 50 1334067445
3 2 100 1334092057
4 4 50 1334065375
4 4 20 1334067436
I’d appreciate any help! Thanks!
You need to get the record with the maximum time.
Here is one method: