Click here to Skip to main content
12,403,983 members (68,952 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MySQL
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 10-Apr-13 4:57am
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can use 'ALTER table' as described in :

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


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

Regards
H.Maadani
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 10 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100