【SQL基础】二:筛选数据

关键字wherelike

  • 简单使用:select cola from tableA where cola = 233; --只返回cola等于233的数据
  • 使用AND操作符:(交集)select cola,colb,colc from tableA where colb=6 and colc=66;
  • 使用or操作符:(并集)select cola,colb,colc from tableA where colb=6 or colc=66;
  • 使用in操作符:(用来指定条件范围)select cola,colb from tableA where colc in ('name1','name2'); --检索colc中name1和name2的数据
  • 使用not操作符:(用来否定其后条件的关键字,类似 != 操作符)select cola from tableA where not colb = 233;
  • 使用通配符 % 进行过滤:(任何字符出现任意次数)select cola from tableA where warframe like 'G%'; --检索cola中G开头的Warframe
  • 使用通配符 _ 进行过滤:(只匹配单个字符)select cola from tableA where warframe like 'A_h';
  • 使用通配符 [](方括号)进行过滤:(匹配指定字符集的一个字符)select cola from tableA where warframe like '[VG]%%%';

where语句的条件操作符:

  • =
  • <> --不等于
  • != --不等于
  • <
  • >
  • <=
  • >=
  • !< --不小于
  • !> --不大于
  • between --指定两个值之间,配合 and 使用
  • is null --为空值
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容