子查询中的Mysql别名

时间:2015-05-27 10:46:27

标签: mysql subquery inner-join

我正在使用Mysql,其中我正在编写以下查询,

SELECT P.pass_id,P.pass_number,
(
SELECT SUM(current_balance) 
FROM (SELECT current_balance 
        FROM `um.user_trs.tariff`
       WHERE user_id = UP.user_id 
       ORDER BY user_tariff_id
       DESC LIMIT 3) AS t1
) AS account_balance  

FROM `ps.pass` P
INNER JOIN `um.user_ps.pass` UP ON UP.pass_id = P.pass_id
WHERE UP.user_id=122;

当我在帐户余额子查询中传递UP.user_id时,我收到以下错误, 执行了1个查询,0个成功,1个错误,0个警告

查询:SELECT P.pass_id,P.pass_number, ( SELECT SUM(current_balance) FROM (SELECT current_balance FROM um.user_trs.tariff WHERE user_...

错误代码:1054 未知栏' UP.user_id'在' where子句'

任何建议都是最受欢迎的 问候 桑杰塔

0 个答案:

没有答案