Mysql SQL更新忽略何处
我需要一些帮助 我正在尝试更新一个连接到另一个表的表,如下表所示:Mysql SQL更新忽略何处,mysql,Mysql,我需要一些帮助 我正在尝试更新一个连接到另一个表的表,如下表所示: table1 ID_Website | descr | level 100 2 104 2 105 3 另一张表: table2 ID | URL 100 www.google.es 104 www.youtube.es
table1
ID_Website | descr | level
100 2
104 2
105 3
另一张表:
table2
ID | URL
100 www.google.es
104 www.youtube.es
105 stackoverflow.com
我试着在“描述”栏上写点东西
UPDATE table1 JOIN table2
SET descr = 'something'
WHERE table1.level = '2'
AND table2.URL = 'www.google.es'
但是,它的意义在于:
table1
ID_Website | descr | level
100 something 2
104 something 2
105 3
我知道问题在于“加入”,因为这毫无意义。但我试着写“FROM”,就像我在其他帖子中读到的一样,它返回了一个语法错误。
创建表时直接连接的两个表,现在sql不允许我们“内部连接”它们(当我们使用SELECT时,不需要进行内部连接)
我不知道如何继续。。。
非常感谢 您缺少
JOIN
中的ON
子句:
UPDATE table1
JOIN table2 ON table1.ID_Website = table2.ID
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SET descr = 'something'
WHERE table1.level = '2'
AND table2.URL = 'www.google.es'
[]您缺少
加入中的ON
子句:
UPDATE table1
JOIN table2 ON table1.ID_Website = table2.ID
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SET descr = 'something'
WHERE table1.level = '2'
AND table2.URL = 'www.google.es'
[]好的,这就是答案,现在它起作用了!谢谢好了,这就是答案,现在它起作用了!谢谢