所以,简单解释:我想从表中的所有记录中按最高家具值(pricelist_furnis_tradevalue.value)排序的games_records乘以记录数量(= games_records.amount)。 furni值在pricelist_furnis_tradevalue中。 现在... pricelist_furnis_tradevalue对于某些家具有多个条目。我只想获得最新的条目,因此应该按pricelist_furnis_tradevalue.time排序。 但是,下面的这个查询返回每个furni /记录的pricelist_furnis_tradevalue的所有条目。SQL加入表格并按乘积值排序
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
这里有2级所需的表的结构
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
我会很感激任何帮助!谢谢!
你试过选择'pricelist_furnis_tradevalue.value * games_records.amount'? – Kermit 2012-07-18 19:49:01
@njk并用AS变量定义它们,然后用ORDER BY变量DESC定义它们? **编辑**试过了。没有工作。 – albin 2012-07-18 19:52:26