我正在尝试从3个表中删除具有相同id的记录。table是这样的:
Table1
+----------+----------------+-----------+---------+----------+
| commonid | creation_date | column 1 | column 2| column 3 |
+----------+----------------+-----------+---------+----------+
Table2
+----------+---------+----------+---------+----------+
| commonid | column 1| column 2 | column 3| column 4 |
+----------+---------+----------+---------+----------+
Table3
+----------+---------+----------+---------+----------+
| commonid | column 1| column 2 | column 3| column 4 |
+----------+---------+----------+---------+----------+
所以要选择我使用的所有数据
SELECT * FROM table1
INNER JOIN table2
ON table1.commonid = table2.commonid
INNER JOIN table3
ON table1.commonid = table3.commonid
WHERE creation_date = '2018-08-01 04:13:50'
返回6行。要删除,我将尝试:
DELETE table1 FROM table1
INNER JOIN table2
ON table1.commonid = table2.commonid
INNER JOIN table3
ON table1.commonid = table3.commonid
WHERE creation_date = '2018-08-01 04:13:50'
返回1行,我本以为是6行。当我再次运行第一个查询时,得到0个结果。表3的总行数不受影响。
如何删除具有相同属性的行 commonid
从每张table上?
1条答案
按热度按时间yftpprvb1#
您需要将所有三个表都指定为删除目标:
目前,您只告诉mysql从
table1
.