MYSQL INSERT SELECT OPTION

hi

how can i use insert select option to add data from one table to another table? first colum from table one and the other column values are jus the same value…

table1 table2
id id date note quantity
1 1 01-09-2016 OK 2
2 2 01-09-2016 OK 2
3 3 01-09-2016 OK 2
4 4 01-09-2016 OK 2
5 5 01-09-2016 OK 2

insert into table2 ( id,date,note,quantity) select id from table1,‘01-09-2016’,‘OK’,2) thank you very much

thank you very much herveo

yes i am tryin to do this but my code doesnt work how can i use this in scriptcase?

$sql_select = ‘SELECT lis_ID FROM analis’;
$insert_sql2 = ‘INSERT INTO hesaphareketi(site_ID,liste_ID,turu,tutar,tarih,aciklama,donem_yil,donem_ay,ktarihi,gel_gid_tah)’
‘SELECT (“1”,lis_ID,“AIDAT”,“275”,“2016-05-31 20:13:19”,“DEN TAHA”,“2016,8,2016-05-31 20:13:19”,“TAH”)
FROM analiste’

sc_exec_sql($insert_sql2);

Hi !
there is a lot of much much experimented scriptcase users than me in this forum.

  • did you test your MySQL commands ?
  • create a Blank Application and Edit OnExecute with something like this :
sc_exec_sql("[I]your SQL[/I]");

Enable your debug mode on the form… your problem is the construct of the query I’m affraid…

‘INSERT INTO hesaphareketi(site_ID,liste_ID,turu,tutar,tarih,ac iklama,donem_yil,donem_ay,ktarihi,gel_gid_tah)’ ------- this is a single string…
‘SELECT (“1”,lis_ID,“AIDAT”,“275”,“2016-05-31 20:13:19”,“DEN TAHA”,“2016,8,2016-05-31 20:13:19”,“TAH”) ------- this is a separated string and you are not concatenating them.
FROM analiste’

Therefor when you assign the strings to your $insert_sql2 variable your code fails…

Good luck with that.

Regards