如何将此查询放入我的PHP代码
SET @prev_value = NULL;
SET @rank_count = 0;
SELECT implement_id, total_implement, percent,CASE
WHEN @prev_value = percent THEN @rank_count
WHEN @prev_value := percent THEN @rank_count := @rank_count + 1
END AS rank
FROM goal_implement
ORDER BY implement_id DESC LIMIT 1
答案 0 :(得分:0)
<?php
$sql = mysql_query("SELECT implement_id, total_implement, percent,CASE
WHEN @prev_value = percent THEN @rank_count
WHEN @prev_value := percent THEN @rank_count := @rank_count + 1
END AS rank
FROM goal_implement
ORDER BY implement_id DESC LIMIT 1");
$result = mysql_fetch_assoc($sql);
?>