选择条款和错误
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 | |
答案 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')