如何为我的 sql 使用 mysql 变量?有时我必须编写一些很长的 sql 连接几个表才能得到结果。我想设置一些变量来缩短我的主 sql,如何在 mysql 中设置变量?
// this is the normal sql
select
a.name,a.money,b.mail
from
(select name, sum(money) from moneys group by name) as a
left join (select name ,email from persons) as b on a.name = b.name
// I want to using variable to make my sql shorter and easy to understand, how to write?
select
a.name,a.money,b.mail
from
var_a
left join var_b