Announcement

Collapse
No announcement yet.

MYSQL INSERT SELECT OPTION

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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



    insertinto table2 ( id,date,note,quantity) selectid from table1,'01-09-2016','OK',2) thank you very much

  • #2
    hope this will help :

    Comment


    • #3
      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,ac iklama,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);

      Comment


      • #4
        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 :
        Code:
        sc_exec_sql("your SQL");

        Comment


        • #5
          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

          Comment

          Working...
          X