格式:
insert into 表A(A表某个字段/全部字段)(select 的语句)
重点:select 的语句的结果集 必须是 A表某个字段/全部字段的值(但字段名称可以对应,毕竟要是只是select的结果)
举一个栗子:
INSERT INTO bid_project (
id,
bidProjectName,
bidProjectAddress,
landArea
projectInformationId
) (
SELECT
b.id,
b.`name`,
a.projectAddress,
a.landArea,
a.id
FROM
project a
LEFT JOIN data_bdst b ON b.projectId = a.id
WHERE
a.isBdstProject = 1
ORDER BY
a.id
)