在SQLite Android中执行以下查询时出现错误
sDataBase.execSQL(query);
insert into Contacts(ID,FirstName,LastName,PhoneNumber,EmailId,Status)
values(‘ae0caa6a-8ff6-d63f-0253-110b20ac2127′,’xxx’,’xxx’,’9008987887′,’xxx@gmail.com’,’Yes’),(‘9afab56e-a18a-47f2-fd62-35c78d8e0d94′,’yyy’,’yyy’,’7890988909′,’yyy@gmail.com’,’Yes’),(‘378d757a-ee60-07a4-e8bc-396b402c3270′,’zzz’,’zzz’,’9000898454′,’zzz@gmail.com’,’Yes’)
注意:这在SQLServer中执行得很好,在Android中出现错误
SQLite的.
Error: sqlite returned: error code = 1, msg = near ",": syntax error, db=/data/data/myapp.contactmanager/databases/webview.db
编辑1:我已添加值之间的空间仍然会出现错误
insert into Contacts(ID, FirstName, LastName, PhoneNumber, EmailId,Status) values
('ae0caa6a-8ff6-d63f-0253-110b20ac2127', 'xxx', 'xxx','9008987887', 'xxx@gmail.com', 'Yes'),
('9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', 'yyy@gmail.com', 'Yes'),
('378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', 'zzz@gmail.com', 'Yes')
INSERT INTO Contacts
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, 'xxx@gmail.com' AS EmailId, 'Yes' AS Status,
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', 'yyy@gmail.com', 'Yes'
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', 'zzz@gmail.com', 'Yes'
编辑3:我在编辑2结束同步状态时犯了一个小错误,该状态在UNION之前已经包含逗号,因此出现错误.现在已删除且工作正常.
INSERT INTO Contacts
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, 'xxx@gmail.com' AS EmailId, 'Yes' AS Status
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', 'yyy@gmail.com', 'Yes'
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', 'zzz@gmail.com', 'Yes'