发表于 2018-10-16 13:47:00

常用的sql语句总结

命令语法  select 字段1,字段2,... from 表名 [ where 表达式 and 表达式 ]
  --其中,select、from、where是不能随便改的,是关键字,支持大小写。
  查看表中的所有信息
  select * from xixi;
  查看表中的id和name

  select>  查看id等于2 的信息

  select>  查看名字是zhangsan的记录

  select>  查看id大于2的记录

  select>  查看id大于2 并且 小于4的记录

  select>  查看表中所有id大于等于5并且小于等于10的数据

  select * from xixi where>  查看表中所有id等于5或者等于10的数据

  select * from xixi where>  查看id不等于5和10之间的数据

  select * from xixi where>
  select * from xixi where>  like结合通配符使用查询   % 表示任意长度的任意字符, _ 表示任意单个字符 ,还支持正则表达式
  select * from xixi where name like 'a%';    --查看name字段中所有以a开头的数据
  使用in关键字指定列表如:
  找出id等于5、6、7中的任意一行的所有数据

  select * from xixi where>
  select * from xixi where>  limit指定行

  select>
  select>  asc正向排序查看(不加默认就是正向排序)

  select>  desc反向排序查看

  select>
  select * from xixi order by>  distinct去重
  select distinct age from xixi;--xixi表的age字段中去除重复的行显示

页: [1]
查看完整版本: 常用的sql语句总结