Updating one table from another table
Same result using a join in a SELECT statement: SELECT "Accounts".*, B."Balance" FROM "Accounts" LEFT JOIN (SELECT "Acct No", "Balance" FROM "Balance History", (SELECT "Acct No", MAX("Balance Date") SELDATE FROM "Balance History" GROUP BY "Acct No") A WHERE "Balance History"."Acct No" = A."Acct No" AND "Balance History"."Balance Date" = A. I understand your advice against keeping balances this way, but you can rest assured that we have reasons for maintaining a history of the account balances.
Additionally, since it is a query, it allows the statement to be stored in the Query section.I have a SQL query where I am trying to update a column in a table (tbl A) from data in another table (tbl B).This works fine when I try to update all the records in tbl A, however, in this case I only have missing data which I have identified and populated in tbl B.But Sales Supplier, Purchase supplier, Wholesale Supplier ..many other columns how can i update in single SQL ( I have to update around 70 columns and some columns may have null values such as Purchase supplier ..)2. You need to have the table you are updating from have a unique or primary key constraint. Secondly you have shown me to update table with "KEY PRESERVED" method. IT NEEDS THIS LOGICALLY regardless of the method used, so just add it (for if a row in OLD joins to more than one row in NEW -- you are hosed, you cannot update this data, therefore NEW has a unique/primary key, add it to facilitate the update) I had a similiar query and i tried applying to my tables.