need help with copy table to table in mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phiber102
    New Member
    • Feb 2009
    • 10

    need help with copy table to table in mysql

    Hello!

    I been working on a problem for a while. I need to copy data from 2 tables and merge them in to 1 table that already exists. i need to extract a column called "bpo" and a column called "usr" from 2 different tables called anv and bpo and then copy them into a table called mybpo.

    I guess it shood look something like this:

    sql = "INSERT INTO mybpo SELECT usr FROM anv where usr ='" & session("usr") & "' and SELECT bpo FROM bpo "

    but i cant get it to work, tried allot of combinations, Please help me

    /Regards Phiber
  • wizardry
    New Member
    • Jan 2009
    • 201

    #2
    hello -

    a couple questions:

    1. are you using this in an app as a function or routine?

    2. or is this a one time copy?

    here is the syntax guide to accomplish this:



    you will need to create a join on those two tables to do you select from or you can do a nested select for your where clause.

    here is info on nested selects:

    Comment

    • phiber102
      New Member
      • Feb 2009
      • 10

      #3
      hi sorry for the late answer its a one time copy every time a user register as a "builder" on the site then all the plans will automatically copy in to the database, with plans + user name on the same id which ofc will increase the number on the "id" tag like :
      usr1+plan1 id=1
      usr1+plan2 id=2
      usr1+plan3 id=3
      usr1+plan4 id=4
      usr1+plan5 id=5
      usr1+plan6 id=6

      usr value and plan value are collected through 2 tables in the database, 1 reason, to make entry for new plans easier and when the user register as builder all plans in the database gets avalible to usr

      thx for help on the statemets :D

      Comment

      Working...