找到你要的答案

Q:mysql, get values from select clause and assign them to variables

Q:MySQL,得到的值分配给变量的选择条款

Is there any way to assign a value, which is acquired from select clause, to a variable so that I can use that variable in other query?

For example, I want to give gold, silver, and bronze medal to first, second, and third place holder respectively.

I have a table(mytable) with records (second), and I will get the name of the top three by

select name from mytable order by second desc limit 3;

and somehow I would like to assign $goldwinner=name1, $silverwinner=name2, $bronzewinner=name3

so that I can use it for

update medaltable set gold = gold + 1 where name = $goldwinner

and same for silver and bronze..

Is there any way I can do this??

有没有办法将一个值从SELECT子句中赋值给一个变量,以便我可以在其他查询中使用这个变量?

例如,我想把金、银、铜牌分别送给第一、二、第三名持有人。

我有一个表(表)的记录(二),我将获得前三名

select name from mytable order by second desc limit 3;

我想给goldwinner美元= name1,silverwinner美元= 2,bronzewinner美元=名字

所以我可以用它

update medaltable set gold = gold + 1 where name = $goldwinner

和银和青铜一样。

我有什么办法可以做到这一点吗??

mysql  variables