`

sql用法小结

SQL 
阅读更多

1.模糊查询:select *from 表名 where 查询字段 like'%biao_'

  %--匹配任意字符        _--匹配单个字符

  2.查找非空项:select *from 表名 where 字段 is not null

  3.集合查询

   union返回两个查询的结果并除其中的重复部分:select 字段1 from 表1 union select 字段1 from  表2

  4.子查询(子查询的条件可以关联主表和子表)

   select *from 表1 where  字段=(select 字段 from 表2 条件)-----子查询的结果必须是唯一

   select * from 表1 where  字段 in(select 字段 from 表2  条件)-----子查询的结果不唯一

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics