transfer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • computerfox
    Contributor
    • Mar 2010
    • 276

    transfer

    hey guys, i had this working before, but when i added another bit, it stopped and now i can't get it to work again

    Code:
    //Put data into right tables
     
    mysql_query("SELECT* FROM inprogress");
    mysql_query("INSERT INTO complete SELECT* FROM inprogress WHERE Status='Y' ");
     
     
    mysql_query("SELECT* FROM complete");
    mysql_query("INSERT INTO inprogress SELECT* FROM complete WHERE Status='N' ");
    is this not how you transfer data?
  • chathura86
    New Member
    • May 2007
    • 227

    #2
    you SQLs are seems to be ok.

    anyway mysql_query("SE LECT* FROM complete");
    and mysql_query("SE LECT* FROM inprogress");
    is not required unless you are executing for another reason.

    but i hope that your table structures are compatible.

    what is the error message you are getting.

    Regards

    Comment

    • computerfox
      Contributor
      • Mar 2010
      • 276

      #3
      not really getting any errors through the web page, but when i tested it in mysql i got something about cols not matching value rows in line 1

      Comment

      • computerfox
        Contributor
        • Mar 2010
        • 276

        #4
        nevermind. careless mistake. thank you anyways :)

        Comment

        • chathura86
          New Member
          • May 2007
          • 227

          #5
          yep that means your tables are not compatible,

          here for an example
          INSERT INTO complete SELECT* FROM inprogress WHERE Status='Y'

          in this query

          SELECT* FROM inprogress WHERE Status='Y will return all the columns
          from inprogress table,

          and then it will try to insert them to complete table

          so the complete table should have the same number of columns and
          their data types should be compatible also

          and it is possible to insert selected values only

          insert into (col1, col2, cols3) (select col1, col2, col3)

          as the summery

          the number of columns in the insert and select should be equal and their
          data types should be compatible.

          insert into user (id, name, email, passwd, ref, joindate) select idm, user_name, email, pass, refferal, sysdate() from db.members;



          Regards

          Comment

          Working...