简体   繁体   中英

insert multiple values from one table to another

I want to insert multiple rows with different value into one table from anthor table which have some device_id but it gives error this is my query

MySqlCommand cmd = new MySqlCommand("INSERT INTO ind_master(ind,device_id) SELECT ind FROM schedule_days WHERE device_id = '"+DBdevice_id+"','"+DBdevice_id+"'", con);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
MySqlCommand cmd = new MySqlCommand("INSERT INTO ind_master(ind,device_id) SELECT ind,'"+DBdevice_id+"' FROM schedule_days WHERE device_id = '"+DBdevice_id+"'", con);

如果device_id为整数,则删除单引号''

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM