I mean I’ve got one table
table1
idbook idauthor title magazine
1 NULL title_1 magazine_1
2 2 title_2 magazine_2
and another
table2
idauthor name surname
1 name_1 surname_1
2 name_2 surname_2
And I want to write a query which update table1 and set value ‘idauthor’ for title_1 the same as the ‘idauthor’ in table2 with name_1.
How it will be look like?Or it is not possible?
How
Actually, the common column is idauthor, it could be thought of as a foreign key. But since there is no way to match table1’s row with table2, you would have to do kind of a dirty update statement, that will ONLY work for the example given above, and not for other scenarios.
This query would update ALL of table1’s rows that have a NULL value in the idauthor column, and set it to the one you’re searching with name_1 and surname_1.