MySQL 1066:即使我已经定义了表别名,也不是唯一的表/别名错误

时间:2012-06-03 15:16:22

标签: mysql sql mysql-5.1 mysql-error-1066

我的Sql查询是

Select a.sum_total FROM
OneWayNetTransactionRes a
LEFT OUTER JOIN
OneWayNetTransactionRes b
ON
a,frm_id = b.to_id
AND a.to_id = b.frm_id

OneWayNetTransactionRes是视图。

CREATE VIEW `OneWayNetTransactionRes` AS
SELECT frm_id, to_id, sum(amount) total_amount
FROM TransactionResolution
GROUP BY frm_id, to_id

然而我收到了错误

1066: Not unique table/alias: 'b'

1 个答案:

答案 0 :(得分:2)

使用.代替,

ON a.frm_id = b.to_id

而不是

ON a,frm_id = b.to_id