gpt4 book ai didi

Mysql传递变量

转载 作者:行者123 更新时间:2023-11-29 21:55:56 27 4
gpt4 key购买 nike

这是我们当前的查询:

SELECT info.yearID, info.nameFirst, info.nameLast, info.HR
FROM (
SELECT a.yearID, a.nameFirst, a.nameLast, a.HR FROM (
SELECT @curRank := @curRank+1 as rank, i.nameFirst, i.nameLast, i.masterID, i.HR, i.yearID
FROM ( SELECT (select @curRank := 0), m.nameFirst, b.yearID, m.nameLast, b.masterId, sum(b.HR) as HR
FROM master as m left join batting as b on b.masterID = m.masterID
WHERE b.yearID = 1882 group by b.masterID)
as i ORDER BY i.HR desc
)a
WHERE a.HR = (SELECT i.HR
FROM (
SELECT (select @curRank := 0), m.nameFirst, b.yearID, m.nameLast, b.masterId, sum(b.HR) as HR
FROM master as m left join batting as b on b.masterID = m.masterID
WHERE b.yearID = 1882
group by b.masterID
)
as i ORDER BY i.HR desc limit 1)) as info ;

我们需要确保 1882 不是硬编码的,而是从 1871 到 2013。

我不是在寻找答案,只是在寻找正确方向的一点。

最佳答案

b.yearID = @yearVar

^^ 该 @ 符号将被解析,并且您处理 @curRank 的方式将类似。它是提供某种类型的动态值(value)的一种手段。

关于Mysql传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33158139/

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