winfwu

导航

MYSQL基础----链接查询(内连接查询,外连接查询)

『1』内连接查询

  employee表

  

  department表

  

  select num,e.d_id,name,age,sex,homeaddr,d.d_name,d.function,d.address

        from employee e,department d

            where e.d_id=d.d_id;

  

 

 

『2』外连接查询

    @左连接(Left Join)查询

    数据表与上面同步

    SELECT num,e.d_id,name,age,sex,homeaddr,d.d_name,d.function,d.address

       FROM employee e left join department d

          ON e.d_id=d.d_id;

  

  @右连接(Right Join)查询

  数据表与上面同步

    SELECT num,e.d_id,name,age,sex,homeaddr,d.d_name,d.function,d.address

       FROM employee e right join department d

          ON e.d_id=d.d_id;

  

posted on 2013-04-02 00:30  winfwu  阅读(312)  评论(0编辑  收藏  举报