zoukankan      html  css  js  c++  java
  • mysql——多表——内连接查询

    内连接查询:可以查询两个或者两个以上的表,当两个表中存在表示相同意义的字段时,可以通过该字段来连接这两个表;

                          当该字段的值相等时,就查询出该记录。

    前期准备两个表:

    create table employee ( num int(50),
                            d_id int(50),
                            name varchar(50),
                            age int(50),
                            sex varchar(50),
                            homeadd varchar(50)
                           );

    insert into employee values(1,1001,'zhangsan',26,'nan','beijing'); insert into employee values(2,1001,'lisi',24,'nv','hunan'); insert into employee values(3,1002,'wangwu',25,'nan','jiangsu'); insert into employee values(4,1004,'aric',15,'nan','yingguo');

    select * from employee;



    create table department ( d_id int(50), d_name varchar(50), functione varchar(50), address varchar(50) );
    insert into department values(1001,'keyanbu','yanfachanpin','3lou5hao'); insert into department values(1002,'shengchanbu','shengchanchanp','5louyiceng'); insert into department values(1003,'xiaoshoubu','cehuaxiaoshou','1louxiaoshoudating');

    select * from department;

     

    执行查询:

    select num,name,employee.d_id,age,sex,d_name,functione from employee,department where employee.d_id = department.d_id;

  • 相关阅读:
    工作态度
    SQL7.0有如下问题:视图字段未及时刷新
    遇到不讲交期的客户
    关于CashFiesta.com
    设置主机多IP技术失败
    已好的客户要建立VSS了
    MSSQL说日志已满
    特殊的四舍五入
    如何保证对帐不遗漏?
    Linux常用命令之其它类型命令汇总
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12093023.html
Copyright © 2011-2022 走看看