首页 >数据库 >mysql教程 >MySQL连表操作_MySQL

MySQL连表操作_MySQL

WBOY
WBOY原创
2016-06-01 13:10:341003浏览

1、自连接

    select * from product where vender_id = (select verder_id from product where name='Dove')

    select p1.* from product p1, product p2 where p1.id = p2.id and p2.name = 'Dove'

 

2、根据同表字段更新

    update product p1,product p2  set p1.photo_status = 2

    where p1.id = p2.id and p2.photo_status is null

 

3、连接要有条件,否则将出现笛卡尔积

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn