模糊查询和正则查询

like用于在where字句中进行模糊查询,sql like 字句中使用%字符来表示任意字符。

select * from 表名 where 字段名 like '模糊配的字符%';Mysql数据库:sql高级查询语句(二)

mysql中对正则表达式的支持有限, 支持部分正则元字符

select * from 表名 where 字段名 regexp '正则表达式';
Mysql数据库:sql高级查询语句(二)

排序

order by 字句来设定想按哪个字段哪种方式来进行排序,再返回搜索结果。

select * from 表名 order by 字段;#默认升序
select * from 表名 order by 字段 desc;#降序
Mysql数据库:sql高级查询语句(二)

分页

limit 字句用于限制由select语句返回的数据数量,或者update,delete语句的操作数量

select * from 表名 where 字段名 limit 数字;
Mysql数据库:sql高级查询语句(二)

联合查询

union 操作符用于连接两个以上的select语句的结果组合到一个结果集合中,多个select语句删除重复的数据。

select * from 表名 where 字段条件 union select * from 表名 where 字段条件;Mysql数据库:sql高级查询语句(二)

多表查询

select 字段1,字段2... from 表1,表2... [where 条件]
Mysql数据库:sql高级查询语句(二)

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-02-08
  • 2021-06-01
  • 2021-08-09
猜你喜欢
  • 2021-09-15
  • 2021-12-04
  • 2022-12-23
  • 2021-12-18
  • 2021-11-15
  • 2021-11-13
  • 2022-02-08
相关资源
相似解决方案