简体   繁体   中英

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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM