1. 程式人生 > >sql 查詢多表插入

sql 查詢多表插入

insert join 插入 parent custom ins sele and article

insert into ArticleCategory_Customer_Edit_Mapping (Customer_Id,ArticleCategory_Id)
//1 少用
SELECT c.Id as CustomerId,a.Id as CategoryId FROM Customer as c CROSS JOIN ArticleCategory as a where c.Id>=781 and c.Id<=937 and (a.Id in (4,8,36) or a.ParentId in(4,8,36))

//2 多數據用
select c.Id as CustomerId,a.Id as CategoryId from Customer c inner join ArticleCategory a on c.Id>=781 and c.Id<=937 and (a.Id in (4,8,36) or a.ParentId in(4,8,36))

sql 查詢多表插入