I have a table [Book] in a database that has a [AuthorId] and [Description] columns. The other table [Author] is related to the [Book] via foreign key [Book].[AuthorId] -> [Author].[ID].
I’d like to update the [Book].[Description] column with the text "Nice book from #Author#", where #Author# is the name of the author taken from the [Author].[Name].
Something like this:
UPDATE [Book] SET [Description] = 'Nice book from ' + [Author].[Name]
but the problem is that I don’t know if there is a way to join the author and the book from within the UPDATE statement, so that each updated row will know it’s author’s name.
Is this possible in a single SQL query?
1 Answer