Connecting Tech Pros Worldwide Help | Site Map

Copy table to table, how?

Newbie
 
Join Date: Feb 2009
Posts: 10
#1: Feb 25 '09
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
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Feb 25 '09

re: Copy table to table, how?


Merge as in JOIN or merge as in UNION?

-- CK
Newbie
 
Join Date: Feb 2009
Posts: 10
#3: Feb 25 '09

re: Copy table to table, how?


Hmm not not really sure, since im not that good at sql/database part :D

But what i want is to take data from table "anv" column "usr" and then take out data from table "bpo" column "bpo", and place them into a table called "mybpo" column "usr" and column "bpo". and its important that usr and bpo enter "next to each other"
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#4: Feb 25 '09

re: Copy table to table, how?


That looks like a JOINED table. Find a key that can be used to link the table, then read this


-- CK
Newbie
 
Join Date: Feb 2009
Posts: 10
#5: Feb 25 '09

re: Copy table to table, how?


Thank you very much! might have saved my day :D
Newbie
 
Join Date: Feb 2009
Posts: 10
#6: Feb 25 '09

re: Copy table to table, how?


hmm i still cant get it to work, doing this now:

Expand|Select|Wrap|Line Numbers
  1. sql = "INSERT INTO mybpo SELECT bpo FROM bpo JOIN anv ON (usr = '" & session("usr") & "')"
  2.  
but then i get error message Microsoft JET Database Engine (0x80040E14)
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#7: Feb 25 '09

re: Copy table to table, how?


1. Display the value of the variable sql.
2. Copy the displayed value
3. Open a query window
4. Paste the value of sql
5. Execute your query.

And check your syntax

-- CK
Newbie
 
Join Date: Feb 2009
Posts: 10
#8: Feb 25 '09

re: Copy table to table, how?


thx again :D appreciate the help
Reply