By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,410 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,410 IT Pros & Developers. It's quick & easy.

Copy table to table, how?

P: 10
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
Feb 25 '09 #1
Share this Question
Share on Google+
7 Replies


ck9663
Expert 2.5K+
P: 2,878
Merge as in JOIN or merge as in UNION?

-- CK
Feb 25 '09 #2

P: 10
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"
Feb 25 '09 #3

ck9663
Expert 2.5K+
P: 2,878
That looks like a JOINED table. Find a key that can be used to link the table, then read this


-- CK
Feb 25 '09 #4

P: 10
Thank you very much! might have saved my day :D
Feb 25 '09 #5

P: 10
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)
Feb 25 '09 #6

ck9663
Expert 2.5K+
P: 2,878
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
Feb 25 '09 #7

P: 10
thx again :D appreciate the help
Feb 25 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.