0

I want to update all the records from 'column1' of 'table1' with the data from 'column2' of 'table2'. This is my code:

UPDATE table1 SET column1 = (SELECT column2 FROM table2);

Unfortunately, I get this message:

Error Code: 1242. Subquery returns more than 1 row

What am I doing wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Jose
  • 25
  • 3
  • 1
    If you run `SELECT column2 FROM table2` by itself, what do you get? -- more than one row! Search for "how can i do an update statement with join in sql" http://stackoverflow.com/questions/1293330/how-can-i-do-an-update-statement-with-join-in-sql – wruckie Sep 19 '14 at 01:38
  • Thanks Wruckie. I solved my problem following the instructions of your link. – Jose Sep 19 '14 at 15:46

0 Answers0