"#1054 - Unknown column ' ' in 'where clause'
答案 0 :(得分:1)
我会回答你的第一个问题。您可以使用INSERT...SELECT语句将数据从一个表复制到另一个表,请参阅示例 -
CREATE TABLE employee1(
EmployeeID INT(11) DEFAULT NULL,
ContactID INT(11) NOT NULL,
ManagerID INT(11) DEFAULT NULL,
Title VARCHAR(50) NOT NULL
);
INSERT INTO employee1 VALUES
(164, 1047, 74, 'Buyer'),
(165, 1192, 74, 'Production Technician - WC50'),
(166, 214, 139, 'Accounts Payable Specialist'),
(167, 1133, 74, 'Production Technician - WC30'),
(168, 1159, 87, 'Production Technician - WC40'),
(169, 1176, 74, 'Production Technician - WC50'),
(170, 1235, 74, 'Scheduling Assistant'),
(171, 1117, 184, 'Production Technician - WC30'),
(172, 1160, 87, 'Production Technician - WC40'),
(173, 1058, 21, 'Production Supervisor - WC30');
CREATE TABLE employee2(
EmployeeID INT(11) DEFAULT NULL,
ContactID INT(11) NOT NULL,
ManagerID INT(11) DEFAULT NULL,
Title VARCHAR(50) NOT NULL
);
INSERT INTO employee2 SELECT * FROM employee1 WHERE ManagerID = 74;
SELECT * FROM employee2;
+------------+-----------+-----------+------------------------------+
| EmployeeID | ContactID | ManagerID | Title |
+------------+-----------+-----------+------------------------------+
| 164 | 1047 | 74 | Buyer |
| 165 | 1192 | 74 | Production Technician - WC50 |
| 167 | 1133 | 74 | Production Technician - WC30 |
| 169 | 1176 | 74 | Production Technician - WC50 |
| 170 | 1235 | 74 | Scheduling Assistant |
+------------+-----------+-----------+------------------------------+
我在查询中添加了WHERE条件,因此这个示例也可以解释您的错误。
答案 1 :(得分:0)
当您收到该错误时,通常意味着它所说的内容,即您正在从具有某些字段的一个表复制到另一个表中,其中缺少一个或多个这些字段。只需确保您拥有两个表中的所有字段,或者当您插入另一个表时使用正确的字段名称。