为什么我在字段列表中得到未知列,我试图从几列中提取数据

时间:2014-11-12 12:49:20

标签: mysql ubuntu

选择条款和错误

mysql> SELECT deviceDetails.lastUpdatedDate,connectionDetails.phoneNumber1,
deviceDetails.simImea1,deviceDetails.simImea2,deviceDetails.model,
connectionDetails.latitude,  connectionDetails.longitude  from connectionDetails c 
inner join deviceDetails d  on (c.deviceUniqueIdentity = d.deviceUniqueIdentity && d.rowStatus='0')  
INTO OUTFILE '/tmp/merged.csv'  FIELDS TERMINATED BY ','  ENCLOSED BY '"' LINES TERMINATED BY '\n';                                                                                                                                                    

错误

   ERROR 1054 (42S22): Unknown column 'deviceDetails.lastUpdatedDate' in 'field list'

表架构

mysql> describe deviceDetails;
+------------------------+--------------+------+-----+---------+-------+
| Field                  | Type         | Null | Key | Default | Extra |
+------------------------+--------------+------+-----+---------+-------+
| activationDate         | bigint(20)   | YES  |     | NULL    |       |
| lastUpdatedDate        | bigint(20)   | YES  |     | NULL    |       |

1 个答案:

答案 0 :(得分:1)

您已经为表创建了别名,因此它们也需要在select

中使用
SELECT 
d.lastUpdatedDate,
c.phoneNumber1,
d.simImea1, 
d.simImea2,
d.model,
c.latitude, 
c.longitude  
from connectionDetails c inner join deviceDetails d  on (c.deviceUniqueIdentity = d.deviceUniqueIdentity && d.rowStatus='0')