gpt4 book ai didi

sql - MySQL 查询 : Winning Auction Bid

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:45 25 4
gpt4 key购买 nike

我有一个小型投标系统,用于幻想拍卖草案。我正在尝试使用以下查询来提高每个玩家的最高出价。但是,它实际上并没有给我最高出价,它只是给我第一个输入数据库的出价。

SELECT Bid.id FROM bids AS Bid 
WHERE Bid.active =1
GROUP BY player_id HAVING MAX( Bid.amount )

这是出价表布局,以防有帮助:

CREATE TABLE IF NOT EXISTS `bids` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user_id` int(10) NOT NULL,
`player_id` int(10) NOT NULL,
`amount` int(6) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`winning_bid` int(1) NOT NULL DEFAULT '0',
`active` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

最佳答案

select max(amount), player_id from bids 
where active = 1
group by player_id
order by 1 desc;

关于sql - MySQL 查询 : Winning Auction Bid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2980927/

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