用于选择具有条件的列的此SQL语句有什么问题

时间:2014-11-12 12:34:04

标签: mysql ubuntu

我试图根据某些条件提取几列。我收到了一个错误。

声明

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';

错误

  

错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的'.phoneNumber1 deviceDetails.simImea1 deviceDetails.simImea2 deviceDetails.model'附近使用正确的语法

3 个答案:

答案 0 :(得分:1)

在列名之间加上逗号。

答案 1 :(得分:1)

在select语句中,列应以逗号,

分隔
SELECT 
deviceDetails.lastUpdatedDate,
connectionDetails.phoneNumber1,
deviceDetails.simImea1,
deviceDetails.simImea2,
deviceDetails.model,
connectionDetails.latitude,
connectionDetails.longitude
from connectionDetails

答案 2 :(得分:1)

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';