1

I have done a lot of updating with MySql and have read a lot of questions and answers on here, but for some reason haven't been able to get my code to work. I keep getting Err 42000 incorrect syntex near Inner, or anything I put here. My code

Update
    Table1
Inner Join
    Table2 on Table2.column = Table1.column
Set
    Table1.column = 'Random'
Where
    table1.ID = '32'
Joker327
  • 65
  • 7

2 Answers2

3

You are nearly there...

Update  Table1
   Set   Table1.column = 'Random'
FROM Table1 
Inner Join  Table2 on Table2.column = Table1.column
Where  table1.ID = '32'

An aliased version would look something like.....

Update  T1
    Set   T1.column = 'Random'
FROM Table1 T1 
Inner Join  Table2 T2 on T2.column = T1.column
Where  T1.ID = '32'
M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • This somewhat worked. To test I decided to do it against 1 specific account, I no longer get the Error Code but it doesn't update any accounts. – Joker327 Feb 26 '15 at 21:11
1

You're close. It's your syntax for your UPDATE statement. Try this:

UPDATE [Table1]
SET [Column] = 'Random'
FROM [Table1]
INNER JOIN [Table2] ON [Table2].[column] = [Table1].[column]
WHERE [Table1].[ID] = '32'
Phoenix
  • 1,881
  • 5
  • 20
  • 28