有两个MySQL表,该更新在针对H2的本地测试模式下工作,并且使用MySQL命令行查询也可以。但是,当Play尝试在演变文件中使用查询时,它将失败。
播放:2.5.6
Scala:2.11.8
查询:
UPDATE table1 t1,table2 t2
SET t1.user_id = t2.id
WHERE t1.buyer_id = t2.buyer_id;
错误:
[info] c.z.h.HikariDataSource - HikariCP pool db is starting.
[error] p.a.d.e.DefaultEvolutionsApi - Syntax error in SQL statement "UPDATE table1 t1,[*]table2 t2
SET t1.user_id = t2.id
WHERE t1.buyer_id = t2.buyer_id;"; expected "SET"; SQL statement:
UPDATE table1 t1,table2 t2
SET t1.user_id = t2.id
WHERE t1.buyer_id = t2.buyer_id[42001-191] [ERROR:42001, SQLSTATE:42001]
最佳答案
update table1 join table 2 on table1.id = table2.id
set table1.name = table2.customername,
table1.mobilenum = table2.phonenum ;
关于mysql - 用另一个表值更新表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40403615/