将一个查询的结果连接到另一个表

时间:2013-10-20 09:33:12

标签: inner-join

我该如何结合这个:

$raw_results = mysql_query("SELECT `item`, (`totalrate` / `nrrates`) AS `rank` FROM `rtgitems` ORDER BY (`totalrate` / `nrrates`) DESC LIMIT 5") or die(mysql_error());

用这个?

INNER JOIN vouchers ON vouchers.item = rtgitems.item

由于

1 个答案:

答案 0 :(得分:0)

将其连成一个查询:

$raw_results = mysql_query("SELECT rtgitems.item, (totalrate / nrrates) AS rank
                            FROM rtgitems 
                            INNER JOIN vouchers ON vouchers.item = rtgitems.item 
                            ORDER BY (totalrate / nrrates) 
                            DESC LIMIT 5") 
               or die(mysql_error());