Insert Issue with Mysql

  • Hello everyone,

    I am a newbie to this community and am quite impressed by the discussions carried out.

    So, I just thought this would be the right place to ask SQL doubts although the problem is with MySQL.

    My problem is:

    I need to insert thousands of records in 2 tables A, B.

    Now table A has a column index_no, an auto-incrementing column.

    When I insert any row in table A, I want that the row in table B should be inserted using the index_no in table A.

    One approach that I am using is,

    Insert a record in table A, get the Index_No value and insert the record in table B with this index_No.

    However for every set of records, there are 3 queries being executed -- insert in A,select from A and insert in B.

    For 10000 records, this figure is 10000*3 = 30000.

    Is there any better way to do it. (like LOAD LOCAL DATA in FILE)

    Thanks

    Akash

    Akash

  • lovesky202005 (11/17/2009)


    So, I just thought this would be the right place to ask SQL doubts although the problem is with MySQL.

    This is a Microsoft SQL Server forum. You might get some MySQL answers here, but we're SQL Server people mostly. You;ll likely get better response and better answers in a forum specifically for MySQL. Try http://www.dbforums.com. They have a MySQL forum there.

    If you have SQL Server questions, we'll be more than happy to help out.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks for the info

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply