zoukankan      html  css  js  c++  java
  • 本周知识整理

     Mysql 语句,指令(以分号结束,多个命令用分好隔开)

    1. 查看数据库: show databases ;

    2. 创建数据库: create database ;

    3. 删除数据库: drop database 库名 ;

    4. 进入数据库: use 库名 ;

    5. 查看所有的表: show tables ;

    6. 数据的增删改查: 

      a. 添加: insert into  表名(字段1,字段2,...)values(值1,值2,...)

      b. 删除: delete from 表名 

      c. 修改: update 表名set 字段1 = 值1 ,字段2 = 值2 ...;

      d. 查询: select 字段1,字段2,... from  表名 ;

    1. 简单查询:select * from 表名 ;

    2. 条件查询:select * from 表名 where 条件 ;多个条件用or 和and 

    3. 模糊查询: like  not like    select* from 表名 where 字段 like"%hei%" ; %代表多个符号,_ 代表单个符号

    4. 排序查询: order by   默认升序[asc]       [desc]降序,  select * from 表名 order by 字段 asc/desc ;

    5. 范围查询: select * from 表名 where 字段 between 50 and 60 ;

                           select * from 表名 where 字段 >50 and 字段<60 ;

    6. 离散查询:  select * from 表名 where 字段 in(值1,值2,值3,...) ;

     in , not in      select * from 表名 where 字段 not in(值1,...) ;

    7.  聚合函数:  sum求和   count条数  max  min   avg

    8. 分页查询: 

    9. 去重查询: distinct   select  distinct 字段 from 表名 ;

    10. 分组查询: group by   having 加条件,不能和where一起用   

                           select * from 表名 group by 字段 having 条件 ;

    11. 连接查询:对列的扩展  select * from 表1,表2 where 表1.a =表2.a and a = '1' ;

                                               select * from 表1 join 表2 on 表1.a =表2.a and a ='1' ;

    12. 联合查询: 对行的扩展 select 字段1 from 表1 union select 字段1 from 表2 ;

    13 子查询: select * from 表1 where 字段2 =(select 字段 from 表2 where 字段= ‘2’) ;

  • 相关阅读:
    利用模板方法模式导出Excel文件
    利用模板方法模式实现导出CSV文件功能
    抽象类多实现,省略this关键字调用实现类方法
    Spring工具类
    DateUtils工具类
    Java获取时间戳
    springMVC接受类型为Map,ajax请求参数类型为字符串将导致的请求400错误
    Set转逗号分隔字符串
    html标签中自定义属性
    编译安装MySQL
  • 原文地址:https://www.cnblogs.com/heyhey/p/7789240.html
Copyright © 2011-2022 走看看