更新 table 时检查几个 table
Checking several tables when updating table
我正在尝试创建一个脚本,如果 static.method_id = methods.method_id 并且 methods.mm_id = [,它将更新 table 静态中的列 lang_id =22=] 和 if languages.is_default = 1。但是这个不起作用,请告诉我,为什么?
UPDATE s
SET s.lang_id = IFNULL(l.lang_id,1)
FROM static as s
JOIN methods as m
ON m.method_id = s.method_id
JOIN languages as l
ON m.mm_id = l.mm_id AND l.is_default = 1
更新。我正在使用 MySQL
在
中出现错误
'FROM merchants__payment_methods_static as s
JOIN merchants__payment_methods as '
这就是 phpMyAdmin 告诉我的
顺便说一句,在 MySQL 中,以下语法正确:
UPDATE static as s
JOIN methods as m
ON m.method_id = s.method_id
JOIN languages as l
ON m.mm_id = l.mm_id AND l.is_default = 1
SET s.lang_id = COALESCE(t.lang_id,1);
使用LEFT
加入:
UPDATE static s
LEFT JOIN methods m ON m.method_id = s.method_id
LEFT JOIN languages l ON m.mm_id = l.mm_id AND l.is_default
SET s.lang_id = COALESCE(l.lang_id, 1);
我正在尝试创建一个脚本,如果 static.method_id = methods.method_id 并且 methods.mm_id = [,它将更新 table 静态中的列 lang_id =22=] 和 if languages.is_default = 1。但是这个不起作用,请告诉我,为什么?
UPDATE s
SET s.lang_id = IFNULL(l.lang_id,1)
FROM static as s
JOIN methods as m
ON m.method_id = s.method_id
JOIN languages as l
ON m.mm_id = l.mm_id AND l.is_default = 1
更新。我正在使用 MySQL 在
中出现错误'FROM merchants__payment_methods_static as s
JOIN merchants__payment_methods as '
这就是 phpMyAdmin 告诉我的
顺便说一句,在 MySQL 中,以下语法正确:
UPDATE static as s
JOIN methods as m
ON m.method_id = s.method_id
JOIN languages as l
ON m.mm_id = l.mm_id AND l.is_default = 1
SET s.lang_id = COALESCE(t.lang_id,1);
使用LEFT
加入:
UPDATE static s
LEFT JOIN methods m ON m.method_id = s.method_id
LEFT JOIN languages l ON m.mm_id = l.mm_id AND l.is_default
SET s.lang_id = COALESCE(l.lang_id, 1);