列名不一定要相同,只要你在HH中列出要插入列的列表跟select from mm表中的选择的列的列表一一对应就可以了,当然两边的数据类型应该是兼容的。
insert into hh (fielda,fieldb,fieldc) select fieldx,fieldy,fieldz from mm
<div class="codetitle"><a style="CURSOR: pointer" data="2405" class="copybut" id="copybut2405" onclick="doCopy('code2405')"> 代码如下:
insert into MetricPoints (MeterID,MetricPointName,[Description],DepartmentID,MediumID)
(SELECT m.MeterID,m.MetricItems+m.InstallPlace as m_MetricPointName,m.MetricItems,m.DepartmentID,m.MediumID
FROM Meters m WHERE NOT EXISTS (SELECT 1 FROM MetricPoints WHERE MetricPoints.MeterID = m.MeterID ) and m.MediumID =2)