Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update query error

Status
Not open for further replies.

dagoat10

Programmer
Jun 3, 2010
74
US
I am trying to update one column of a table from another column of another table, but i keep getting errors

here is what i have tried:
mysql> Update NFL_Players2
-> SET Number = Player2.Number
-> Where NFL_Players2.Number = Player2.Number;
ERROR 1109: Unknown table 'Player2' in where clause

Also i have tried this:
mysql> Update NFL_Players2 INNER JOIN Player2
-> ON Player2.Player = NFL_Players2.Player
-> SET NFL_Players2.Number = Player2.Number
-> WHERE Player2.Player = "Derek Anderson";
ERROR 1064: You have an error in your SQL syntax near 'INNER JOIN Player2
ON Player2.Player = NFL_Players2.Player
SET NFL_Players2.Numb' at line 1


All the necessary tables exist, so what is missing?
 
mysql Ver 11.18 Distrib 3.23.54, for pc-linux (i686)
 
3.23 is oooooooooold, and does not support JOIN syntax

try it like this --
Code:
UPDATE NFL_Players2 
     , Player2
   SET NFL_Players2.Number = Player2.Number
 WHERE Player2.Player = NFL_Players2.Player
   AND Player2.Player = 'Derek Anderson'
:)



r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
oh, wait... scratch that

3.23 is ~too~ old

daManual said:
Starting with MySQL 4.0.4, you can also perform UPDATE operations that cover multiple tables
looks like you are outta luck



r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top