在我输入值的行上不断出现错误,它特别出现在" 15" " 15 Water Road",与VALUES相同。错误说明:
"语法错误:缺少右括号"。
当我尝试在XAMPP上运行时,我得到:
"您的SQL语法出错了;检查与您的MariaDB服务器版本对应的手册,以便在Water Rd,0412345678,750,3)附近使用正确的语法,(2,Smith,2,14 Water Rd,0412345679,400,4),& #34;
对DB和SQL来说非常新,任何帮助都会非常感激。
CREATE TABLE Customer_info (
CustomerID int,
LastName varchar(50),
Username int,
Address varchar(777),
PhoneNumber int,
TotalSpent int,
OrdersCompleted int
);
INSERT INTO Customer_info (CustomerID, LastName, Username, Address, PhoneNumber, TotalSpent, OrdersCompleted)
VALUES (1, Mason, 1, 15 Water Rd, 0412345678, 750, 3), (2, Smith, 2, 14 Water Rd, 0412345679, 400, 4),
(3, Lens, 3, 1 Water rd, 0412345671, 700, 7), (4, Marks, 4, 5 Fire Rd, 0412345672, 100, 1),
(5, Barr, 5, 19 Fire Rd, 0412345673, 500, 1), (6, Blok, 6, 21 Fire Rd, 0412345674, 1000, 10),
(7, Pume, 7, 21 Water Rd, 0412345675, 1000, 2), (8, Po, 8, 77 Earth Rd, 0412345676, 1000, 4),
(9, Adid, 9, 20 Earth Rd, 0412345677, 2, 200), (10, Lew, 10, 6 Earth Rd, 0412345679, 250, 1),
(11, Chia, 11, 1 Earth Rd, 0412345681, 150, 1), (12, Barrett, 12, 11 Wind Rd, 0412345682, 450, 9),
(13, James, 13, 9 Wind Rd, 0412345683, 250, 10), (14, Foop, 14, 2 Window St, 0412345684, 200, 10),
(15, Watch, 15, 8 Window St, 0412345685, 1200, 1), (16, Irving, 16, 11 Window St, 0412345686, 1400, 2),
(17, Jones, 17, 22 Window St, 0412345687, 1600, 2);
答案 0 :(得分:1)
您应该使用(单个)引号将非数字值括起来。
这里的错误有点神秘,但是发生了什么,当数据库引擎试图解析你要插入的内容时,它不知道应该如何使用这些字符 - 例如,逗号是否属于字符串与否(请记住,它不知道地址字段不太可能包含逗号)。
答案 1 :(得分:0)
您没有在引号内包含varchar元素,因此错误地读取地址值并抛出错误,将姓氏和地址括在引号中并插入这将解决问题
INSERT INTO Customer_info (CustomerID, LastName, Username, Address, PhoneNumber, TotalSpent, OrdersCompleted) VALUES (1, 'Mason', 1, '15 Water Rd', 0412345678, 750, 3),(1, 'Mason', 1, '15 Water Rd', 0412345678, 750, 3);
答案 2 :(得分:0)
<?php
CREATE TABLE Customer_info (
CustomerID int,
LastName varchar(50),
Username int,
Address varchar(777),
PhoneNumber int,
TotalSpent int,
OrdersCompleted int
);
"INSERT INTO Customer_info('CustomerID','LastName','Username','Address','PhoneNumber','TotalSpent','OrdersCompleted')VALUES
('1', 'Mason','1','15 Water Rd','0412345678','750','3'),
('2', 'Smith','2','14 Water Rd','0412345679','400','4'),
('3', 'Lens','3','1 Water rd','0412345671','700','7'),
('4', 'Marks','4','5 Fire Rd','0412345672','100','1'),
('5', 'Barr', '5', '19 Fire Rd','0412345673','500','1'),
('6','Blok','6','21 Fire Rd','0412345674','1000','10'),
('7','Pume','7','21 Water Rd','0412345675','1000','2'),
('8','Po','8','77 Earth Rd','0412345676','1000','4'),
('9','Adid','9','20 Earth Rd','0412345677','2','200'),
('10', 'Lew', '10','6 Earth Rd','0412345679', '250', '1'),
('11','Chia','11','1 Earth Rd','0412345681','150','1'),
('12','Barrett','12','11 Wind Rd','0412345682','450','9'),
('13','James','13','9 Wind Rd','0412345683','250','10'),
('14', 'Foop','14','2 Window St','0412345684','200', '10'),
('15','Watch','15','8 Window St','0412345685','1200','1'),
('16', 'Irving', '16', '11 Window St', '0412345686', '1400', '2'),
('17', 'Jones', '17', '22 Window St', '0412345687', '1600', '2')";
?>