You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thanks for creating this repo. It really has helped me a lot in getting started with SQL.
Now as posted in the solutions for exercise 7, the solution, I feel, is quite static. So, I searched about the error, Error Code: 1093. You can't specify target table 'albums' for update in FROM clause I got while trying to solve it in a single query. The following solution works dynamically:
UPDATE albums
SET release_year =1986WHEREalbums.id= (
SELECT id
FROM (SELECTa.idFROM albums AS a
WHERE release_year IS NULL) AS c
);
Upon reading this article I found that the above used to be a complex query in earlier versions of MYSQL which involved creating a temporary table. But starting from version 5.6 onward it has been optimised. So, I assume it is safe to use.
Also, coming from python background, this feels quite satisfying to do the task in one line (query in this case).
The text was updated successfully, but these errors were encountered:
First off, thanks for creating this repo. It really has helped me a lot in getting started with SQL.
Now as posted in the solutions for exercise 7, the solution, I feel, is quite static. So, I searched about the error,
Error Code: 1093. You can't specify target table 'albums' for update in FROM clause
I got while trying to solve it in a single query. The following solution works dynamically:Upon reading this article I found that the above used to be a complex query in earlier versions of MYSQL which involved creating a temporary table. But starting from version
5.6
onward it has been optimised. So, I assume it is safe to use.Also, coming from python background, this feels quite satisfying to do the task in one line (query in this case).
The text was updated successfully, but these errors were encountered: