MySQL Forums
Forum List  »  Newbie

Basic sub-query in an UPDATE statement
Posted by: Harland Oracle
Date: June 19, 2021 07:32AM

All:
I am trying to update a 'batting' table with the TEAMNAME from the 'teams' table and I'm getting a 'sub-query contains more than 1 row' error

batting table - TeamName, TeamID
teams table - Team, TeamID
(TeamName and Team are supposed to be the same)

Guess I don't know how to do it...

UPDATE batting
SET TeamName=(SELECT name
FROM teams
WHERE teamID=teams.teamID);

Options: ReplyQuote


Subject
Written By
Posted
Basic sub-query in an UPDATE statement
June 19, 2021 07:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.