Click to See Complete Forum and Search --> : insert records from another table by select


do_singh
04-07-2008, 10:27 AM
hope someone can help.

i'm trying ot get the data from one table in to another and have written the script below

INSERT INTO UDNA_UG_ID
SELECT UG_ID
FROM USERS
WHERE (UG_ID = USER_DNA_TEST.UDNA_U_ID)

but it's not working

any hints

chazzy
04-07-2008, 11:03 AM
it looks like you want to use a join somehow.

PhilgB
04-07-2008, 05:41 PM
I think he wants to insert the results of a select into another table.

Something like:

INSERT INTO table2 (field1, field2) SELECT field1, field2 FROM table1 WHERE...

chazzy
04-07-2008, 06:30 PM
Right... but he references a table/prefix/view "USER_DNA_TEST" that's not mentioned anywhere... so I'd think that we'd need to introduce it some point, via a join?

PhilgB
04-08-2008, 08:12 AM
Oh didn't even see that. Need more info from the OP I guess.