Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
Posted
Updated 10-Apr-13 5:56am
v3
Comments
joshrduncan2012 10-Apr-13 11:14am    
Can you show us the code that you have already and pinpoint where the issue is?
Member 9611735 10-Apr-13 11:23am    
Question has been updated with code

1 solution

You can use 'ALTER table' as described in :

http://www.w3schools.com/sql/sql_alter.asp[^]


-------------------------------

Regards
H.Maadani
 
Share this answer
 
Comments
Member 9611735 10-Apr-13 11:54am    
the column already exists in table, I just want to extend query and insert value into column

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900