MySql多表联结查询与多表关联数据同时删除
left join语法
代码如下 | |
table_references: |
例:
代码如下 | |
mysql> CREATE TABLE `product` ( |
查询
代码如下 | |
mysql> SELECT * FROM product LEFT JOIN product_details |
超级简单吧,那么有朋友问我怎么在MySQL中实现多表关联数据同时删除
category中的id(栏目编号)字段作为该表的主键(primary key).唯一标识了一个栏目的信息。
news 中的id字段作为该表的主键(primary key).唯一标识了一个栏目的信息。
category_id(栏目编号)字段与category表的id字段相关联。
1.SQL删除语句
代码如下 | |
delete category,news from category left join news on category.id = news.category_id |