Sql updating a table with values from another table

There are 2 tables linked through a primary key and if the values in one table change, the corresponding values in another table should be changed and reflected accordingly.Does someone know what logic I need to apply for this to work ?That will help me decide if the method I am considering explaining to you is likely to work.Hi, I am very new to SQL and really dont know how to phrase my question.

The first is to add one record at a time; the second is to add many records at a time.Do I have to create a primary key-foreign key relationship and then create a trigger on the other table on which the values need to be updated ?The values in the table will be changed through a webpage. sounds like you want to echo the same value in two places, is that correct?You probably should use a single stored procedure to first update the values in the base-table.Include a second update statement in this stored procedure to update the values in the related table.create procedure ()asbeginupdate set =, ... where =end ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’!They can connect to each other by a column called UNIQUE_IDA UNIQUE_ID will have only one row in contact information table but there could be multiple rows for that UNIQUE_ID in professional information.In the ideal world, I would know how to create an SQL query to pull and filter results as I need it.so if i change one table, it copies the same value to a related record in another?if the above assumption is true, here's my thoughts: This is breaking the whole normal forms rule: if a value is in one table, and there is a relationship between the two tables anyway, you can always join the tables together to get the value when it needs to be displayed in reference to the second table, so you want to try and avoid i'd say it's better to drop the column in the second table, and get the value in a query;you could also create a view with that query above, to make it easier to access;another possibility is to replace the column in table 2 with a calculated field, and the calculated field calls a user defined function that effectively gets the value you want from the other table, based on the join/relationship between the two.In both cases, you use the SQL statement INSERT INTO to accomplish the task.INSERT INTO statements are commonly referred to as append queries.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “sql updating a table with values from another table”