mysqlsqlmysql-5.1mysql-error-1066

MySQL 1066: Not unique table/alias error even though I have defined table alias


My Sql query is

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

Where OneWayNetTransactionRes is a view.

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

Yet I get the error

1066: Not unique table/alias: 'b'

Solution

  • Use a . instead of ,:

    ON a.frm_id = b.to_id
    

    instead of

    ON a,frm_id = b.to_id