Help with inserting values from information not found in another table

J

Joey Martin

I have a tmp_phone that I am comparing to table_phonelistings using the
phone field.

I then want to insert the values (ac,phone) from the tmp_phone table NOT
IN table_phonelistings, into the table_phonelistings.

I think I am doing an incorrect loop as it's timing out. Any help is
appreciated. Here is what I have:

sql2="select ac,phone from tmp_phone where phone not in (select phone
from table_phonelistings)"
set rs=conn.execute(sql2)
sql3="insert into table_phonelistings (areacode,phone) values ('" &
rs("ac") & "','" & rs("phone") & "')"
conn.execute(sql3)
do while not rs.eof
loop
conn.close
 
B

Bob Barrows

Only one SQL command is needed:

sql = "Insert into table_phonelistings (areacode,phone) " & _
"Select ac,phone from tmp_phone where phone not in " & _
"(select phone from table_phonelistings)"

conn.execute sql,,1 '1=adCmdText

see below for an explanation of your time out:

Joey said:
do while not rs.eof

You don't have any code inside this loop! of course it's timing out. Well,
you don't need the loop anyways.

HTH,
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top