Updating records from one table to another table

Forum for DBF Commander discussing.

Updating records from one table to another table

Postby audidriver » Mon May 07, 2012 8:16 pm

I have roughly 500 records that I need to update in my table. I want to take my original table named "mytable" and update the value in the column "dev" to the value in the column "dev" of the second table "newtable". The updated will take place when the email in "newtable" matches and email in the "mytable"
Here is it written out another way

Original Table - mytable

Email Dev
example@example.com YES


Second Table - newtable

Email Dev
example@example.com Need this value


I tried this but it doesn't work as it doesn't see the second table
UPDATE table SET 'column' = 'O' WHERE email IN (SELECT email FROM table2)
audidriver
 
Posts: 2
Joined: Fri Jan 13, 2012 5:14 am

Re: Updating records from one table to another table

Postby Admin » Tue May 08, 2012 8:09 am

Hi,
thanks for the question.

You shouldn't quote field name in a query. Also, if your tables are not in the same folder, you should use full file name in your SQL query text. E.g.:
Code: Select all
UPDATE "D:\Folder1\table.dbf" SET column = 'O' WHERE email IN (SELECT email FROM "D:\Folder2\table2.dbf")

(use 'Edit -> Insert Current Filename' command in order to quick add current DBF's full file name to the SQL query text)

More info on UPDATE SQL statement and additional examples you can find here: http://dbf-software.com/sql-update.html
Best regards,
Oleg Zhechkov
User avatar
Admin
Site Admin
 
Posts: 124
Joined: Wed Apr 21, 2010 7:27 pm


Return to DBF Commander Professional

Who is online

Users browsing this forum: No registered users and 9 guests

cron