我正在将记录从一个表插入到状态为 lead 的另一个表中。现在,由于两个表中的列数不同,我必须使用字段名称。然而它失败了。不知道是哪里的原因
INSERT IGNORE INTO Table1(
lead_id,
phone_number,
title,
first_name,
middle_initial,
last_name,
address1,
address2,
address3,
city,
state,
postal_code,
gender,
date_of_birth,
alt_phone,
email,
comments,
question_id,
answer_ques,
situation_id,
best_time_contact,
specific_datetime,
specific_datetime_at,
leadcreated_by,
leadcreated_by_on,
leadcreated_by_at,
transfer_by,
product_id,
insertDTS
)
SELECT
lead_id,
phone_number,
title,
first_name,
middle_initial,
last_name,
address1,
address2,
address3,
city,
state,
postal_code,
gender,
date_of_birth,
alt_phone,
email,
comments,
question_id,
answer_ques,
situation_id,
best_time_contact,
specific_datetime,
specific_datetime_at,
leadcreated_by,
leadcreated_by_on,
leadcreated_by_at,
transfer_by,
product_id,
insertDTS
FROM TABLE2
WHERE TABLE2.status = 'LEAD'
这会起作用..不需要值 ---谢谢
最佳答案
据我对 mySql 的了解,您不能在同一插入语句中同时使用 VALUES 和 SELECT。尝试从语句中删除 VALUES。
MySQL 文档显示了 insert...values、insert...set 和 insert...select 语句的单独语法。
关于mysql - 查询在选择值时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4859142/