本文介绍了从另一个表插入新表值并将新值插入新表中的唯一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用另一个表中的值创建一个新表。我到目前为止的查询是从现有表中获取值并将它们插入到新表中,但我试图找到将值插入新表中的唯一列以及使用另一个表中的值的语法。任何人都可以帮助我吗?



MySqlConnection conn = new MySqlConnection(connectionSQL);

conn.Open();

MySqlCommand cmd = new MySqlCommand(INSERT INTO TransactionsTemp(条形码,名称,价格)SELECT条形码,名称,价格FROM Product WHERE barcode =''+ textBox1.Text +'',conn);

cmd.ExecuteNonQuery();



conn.Close();

I am trying to create a new table using values from another table. The query I have so far is getting values from an existing table and inserting them into the new table, but I am trying to find the syntax for inserting a value into a unique column in new table as well as using values from another table. Can anybody help me?

MySqlConnection conn = new MySqlConnection(connectionSQL);
conn.Open();
MySqlCommand cmd = new MySqlCommand("INSERT INTO TransactionsTemp(barcode, name, price) SELECT barcode, name, price FROM Product WHERE barcode=''" + textBox1.Text + "''", conn);
cmd.ExecuteNonQuery();

conn.Close();

推荐答案


这篇关于从另一个表插入新表值并将新值插入新表中的唯一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-22 12:50