Home > Database > Mysql Tutorial > MySQL连表操作_MySQL

MySQL连表操作_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:10:34
Original
1037 people have browsed it

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、连接要有条件,否则将出现笛卡尔积

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template