Search code examples
mysqlsqlinner-joinmysql-5.7

mysql syntax error with inner join on two tables


I have this sql query:

update edi_file_steps 
set 
    table_A.user_id= table_B.id ,
    table_A.message= SUBSTRING_INDEX(table_A.message,'[',1)
FROM 
    edi_file.steps AS table_A INNER JOIN GU_User as table_B
where 
   message LIKE '%Downloaded%'AND table_B.login = 'Jack'

But I am getting mysql syntax error. Is there a problem with my syntax? I am using mysql 5.7.


Solution

  • You can't use FROM in an UPDATE query, you specify the table after the UPDATE statement:

    UPDATE edi_file_steps table_A
    INNER JOIN GU_User AS table_B
    SET 
        table_A.user_id= table_B.id ,
        table_A.message= SUBSTRING_INDEX(table_A.message,'[',1)
    WHERE 
        message LIKE '%Downloaded%'AND table_B.login = 'Jack'