product_info表:
product_info_link表:
1.查询
查询platformcode为002的商品信息:
SELECT pi.* FROM `product_info` as pi,product_info_link as pil where pi.product_id = pil.product_id and pil.platformcode = '002'
查询结果:
2.更新
更新platformcode为001的商品库存为31:
UPDATE product_info,product_info_link set product_stock = 31 where product_info.product_id = product_info_link.product_id and product_info_link.platformcode = '002'
3.删除
- 删除product_info表platformcode为001的商品信息:
DELETE product_info from product_info,product_info_link where product_info.product_id = product_info_link.product_id and product_info_link.platformcode = '001'
product_info表少了一条数据,product_info_link表没有少
- 同时删除两个表platformcode为001的关联数据
DELETE product_info,product_info_link from product_info LEFT JOIN product_info_link on product_info.product_id = product_info_link.product_id where product_info_link.platformcode = '001'
product_info表,product_info_link表都少了一条数据