有两个MySQL表,更新在针对H2的本地测试模式下工作,使用MySQL命令行查询也很好。但是当Play尝试在进化文件中使用查询时,它会失败。
比赛:2.5.6 斯卡拉: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]
答案 0 :(得分:1)
update table1 join table 2 on table1.id = table2.id
set table1.name = table2.customername,
table1.mobilenum = table2.phonenum ;
答案 1 :(得分:0)
<强>查询强>
UPDATE table1 t1
JOIN table2 t2
ON t1.buyer_id = t2.buyer_id
SET t1.user_id = t2.id;