zoukankan      html  css  js  c++  java
  • mysql(七)

    多表查询:

      显示内连接:

        select 字段列表 from 表名1  inner  join 表名1 on  条件 

        * inner 可忽略

        select * from student inner  join  class on student.clas_id=class.id

      隐式内连接:

        使用where:

          select  t1.name,t2.name from student t1,class  t2 where t1.class_id=t2.id

      外连接:

        左外链接

        右外链接

        *outer一般忽略

        select * from student left  join outer class on student.clas_id=class.id

    子查询:

       select *from student where class_id = (select max(class_id) from student)

       select *from student where class_id in (select id from student where id=2 or id =3)

       select *from student  t1 ,(select *from class where class.id>2) where t1.class_id=t2.id

  • 相关阅读:
    Model1简介
    修改Maven的本地仓库地址
    JavaWeb实现上传文件
    数据库
    集合
    JavaWeb
    Java基础
    Redis 中 redis.conf配置详细解析
    利用Java生成二维码
    利用dom4j读写XML
  • 原文地址:https://www.cnblogs.com/saber-xi/p/10680754.html
Copyright © 2011-2022 走看看