sql把如何两个表数据插入到一个表中?
OleDbConnection mycon = null;
try
{
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\1.mdb;";
mycon = new OleDbConnection(strcon);
mycon.Open();
string sql = "insert into temp select DISTINCT danwei.单位编码,danwei.单位名称,sale.单据编号 from sale,danwei where danwei.单位名称=sale.单位名称";
OleDbDataAdapter ad = new OleDbDataAdapter(sql, strcon);
DataTable dt = new DataTable();
ad.Fill(dt);
textBox3.Text = "导入完成";
}
finally
{
mycon.Close();
}
现在只能把danwei.单位编码,danwei.单位名称插入到temp中,sale.单据编号怎么也添加不了,该怎么写呀?
------解决方案--------------------