UPDATE summary_data SET current_category = (SELECT category_id FROM products WHERE products.product_id = summary_data.product_id) WHERE EXISTS (SELECT category_id FROM products WHERE products.product_id = summary_data.product_id); If you want to test your skills using the SQL UPDATE statement, try some of our practice exercises.These exercises allow you to try out your skills with the UPDATE statement.You say you have 2 tables, but you show the definition for 3 tables. AND (C.column1, C.column2, C.column3) IS DISTINCT FROM (A.column1, B.column2, A.column1 + B.column2) clause is optional to avoid empty updates that would not change anything (but still write a new row version at full cost).You say you are attempting to create a table, but show the code for updating rows within an existing table. If your intent is to insert rows from A+B into C, you likely want to use an INSERT statement. @ypercube already gave a basic explanation in his comment.
There are, in fact, two separate sets of ISO codes, 2-letter and 3-letter, so you may not in reality be able to join these columns: edited There is a difference in behavior to my version - your version will set it to NULL if it's not found, mine will not alter an existing value if it's not matched. Also the execution plan may differ depending upon the [email protected] It's probably not a problem - when you add the new column, I'm assuming it will be NULL and also a foreign key, so invalid entries wouldn't be allowed anyway.But it's hard to tell from what has been explicitly given in your question.You will be given questions that you need to solve.After each exercise, we provide the solution so you can check your answer. I have always preferred to use SQL versus SAS syntax because of the wider usage of SQL for general data manipulation.
However, I have heard that the SAS update statement is much more efficient than SQL for updates, so I wrote a test case to verify.