gpt4 book ai didi

php - 回显 MySQL 查询的单个结果

转载 作者:行者123 更新时间:2023-11-29 08:28:53 25 4
gpt4 key购买 nike

我有以下 MySQL 查询;

    SELECT *, @rownum := @rownum + 1 from
(
SELECT (display_name) 'Author',
IFNULL(ROUND(SUM(balance.meta_value),2),2) 'Balance'
FROM posts p
JOIN users u
ON p.post_author = u.ID
JOIN postmeta odd ON p.ID = odd.post_id AND odd.meta_key = 'odd' AND odd.meta_value >= 1.5
LEFT JOIN postmeta balance
ON p.ID = balance.post_id AND balance.meta_key = 'balance'
WHERE p.post_status = 'publish' and p.post_author = 'User1'
GROUP BY u.ID
ORDER BY Balance DESC
)x, (SELECT @rownum := 0) r

生成下表;

 Users      Balance       @rownum := 0       @rownum := @rownum + 1
User1 5.88 0 1
User2 -23.41 0 2

如何回显第一个用户最后一列的值(其中 [@rownum := @rownum + 1] = 1。

谢谢

最佳答案

$result = mysql_query("your's sql query");
$row = mysql_fetch_array($result);
echo $row[2];

这是针对您的具体问题的代码。了解更多关于 here 。整个扩展已被弃用,因此您的作业请阅读 this并重写我的代码。

关于php - 回显 MySQL 查询的单个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com