<?php
$query1 = "CREATE VIEW current_rankings AS SELECT * FROM main_table WHERE date = X";
$query2 = "CREATE VIEW previous_rankings AS SELECT rank FROM main_table WHERE date = date_sub( X , INTERVAL 1 MONTH)";
$query3 = "CREATE VIEW final_output AS SELECT current_rankings.player, current_rankings.rank as current_rank LEFT JOIN previous_rankings.rank as prev_rank
ON (current_rankings.player = previous_rankings.player)";
$query4 = "SELECT *, @rank_change = prev_rank - current_rank as rank_change from final_output";
$result = mysql_query($query4) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo $row[ player ]. $row[ current_rank ]. $row[ prev_rank ]. $row[ rank_change ];
}
?>
All the queries work independently but am really struggling putting all the pieces together in one single result so I can use it with mysql_fetch_array.
我试图提出看法和临时表格,但每次都说桌上不存在,或回到空洞的阵列圈......当时有这样的情况,但我认为,由于这是我第一次必须处理多个问题,我需要将所有问题合并在一起。 期待得到一些支持。 许多感谢。