Ask Your Question

Need help with updating records based on a query with multiple tables [closed]

asked 2019-05-07 19:53:10 +0200

TGM gravatar image

updated 2019-05-07 19:54:17 +0200

I apologize but, I am an absolute newbie when it comes to databases and SQL. I am working on a database for my radio club (I am the only one that was willing to give it a try) and I am having a problem with updating a table field after a query. I am using LO Version: (x64) on Windows 10.

I am wanting to locate the records in tbl_Old that are not in tbl_New and flag the records for manual updating.

This is a sample of the tables that I am using:

image description image description

Running (in Tools>SQL): SELECT "Record" FROM "tbl_Old" WHERE "Record" NOT IN ( SELECT "Record" FROM "tbl_New" )

Returns the expected
image description

This is where I am hitting the snag, and have not been able to find a solution. I want tbl_Old to be updated to this:

image description

I have searched and searched and have been unable to find anything that will work. I am able to update ALL of the tbl_Old.Flag with UPDATE "tbl_Old" SET "Flag" = 'D' but I want to only update the selected records. Any ideas on how to do this?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by TGM
close date 2019-05-08 17:29:01.573443

1 Answer

Sort by » oldest newest most voted

answered 2019-05-08 11:40:55 +0200

Rolandvl gravatar image

execute following sql:

UPDATE "tbl_Old" SET "Flag" = 'D' WHERE "tbl_Old"."Record" NOT IN (SELECT "Record" FROM "tbl_New")

edit flag offensive delete link more


I could have SWORN that I had tried that SQL and it did not work but, I must have been wrong, worked perfect. Thank you very much.

TGM gravatar imageTGM ( 2019-05-08 17:14:29 +0200 )edit

Question Tools

1 follower


Asked: 2019-05-07 19:53:10 +0200

Seen: 25 times

Last updated: May 08