带有内连接的'on子句'中的未知列

时间:2016-09-21 19:37:44

标签: mysql

我的桌子

ea_users

  

| id |电子邮件|电话| id_cellcarrier |

ea_cellcarrier

  

| id | cellurl |

我想:

  

|电子邮件|电话| cellurl |

我的SQL语句

SELECT ea_users.email, ea_users.phone_number, ea_cellcarrier.cellurl 
FROM ea_users, ea_cellcarrier 
INNER JOIN ea_cellcarrier AS c2
ON ea_users.id_cellcarrier = c2.id

我得到: 'on clause'

中的未知列'ea_users.id_cellcarrier'

我做错了什么?

2 个答案:

答案 0 :(得分:1)

您的查询应该被重写

SELECT e.email, e.phone, c2.cellurl 
FROM ea_users e
INNER JOIN ea_cellcarrier c2
ON e.id_cellcarrier = c2.id

此外,看起来ea_users的列名是phone,对吗?

答案 1 :(得分:0)

这有效:

SELECT ea_users.email, ea_users.phone_number, ea_cellcarrier.cellurl 
FROM ea_users 
INNER JOIN ea_cellcarrier
ON ea_users.id_cellcarrier = ea_cellcarrier.id