Answer the question
In order to leave comments, you need to log in
How to change values in one table by taking values from another?
Hi guys! Tell the fool how it is possible to implement the following.
There is a database. There are 2 tables in the database (below: name - structure):
1. tab.1 - || second name | last name | third name | key ||
2.tab.2 - || second name | last name | Third Name ||
I need to take records from tab.2 with values: 'SecondName', 'LastName', 'ThirdName', and in tab.1 for these records, update the Key value.
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
And where are the primary keys in the tables?
In general, if the tables are some copies of each other, then the updates of the records are handled something like this.
update tab1 t1, tab2 t2 // таблицы, участвующие в Update
set t1.key = ? // устанавливаем параметр key, только непонятно, что задаем
where t1.id = t2.id // соответствие записей по первичным ключам
update tab1 t1, tab2 t2 // таблицы, участвующие в Update
set t1.key = ? // устанавливаем параметр key, только непонятно, что задаем
where t1.SecondName = t2.SecondName // допустим, пусть будет обновление key у тех записей, у которых есть полное соответствие атрибутов.
and t1.LastName = t2.LastName
and t1.ThirdName = t2.ThirdName
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question