mysql学习--mysql必知必会1_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql学习--mysql必知必会1_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2264字,纯文字阅读大概需要4分钟。
内容图文
![mysql学习--mysql必知必会1_MySQL](/upload/InfoBanner/zyjiaocheng/578/d41b1d8ed33f4b34895b2999605e9715.jpg)
如下为mysql必知必会第九章开始:
正则表达式用于匹配特殊的字符集合。mysql通过where子句对正则表达式提供初步的支持。
关键字regexp用来表示后面跟的东西作为正则表达式处理。
(.)是正则表达式的一个符号,表示匹配任意一个字符:
mysql> select prod_name -> from products -> where prod_name regexp '.000' -> order by prod_name;+--------------+| prod_name |+--------------+| JetPack 1000 || JetPack 2000 |+--------------+2 rows in set (0.14 sec)
|匹配符:
表示匹配其中之一
mysql> select prod_name -> from products -> where prod_name REGEXP '1000|2000' -> ORDER BY prod_name;+--------------+| prod_name |+--------------+| JetPack 1000 || JetPack 2000 |+--------------+2 rows in set (0.00 sec)
[]匹配符: 匹配几个字符之一
2 rows in set (0.00 sec)mysql> select prod_name -> from products -> where prod_name regexp '[123] Ton' -> ;+-------------+| prod_name |+-------------+| 1 ton anvil || 2 ton anvil |+-------------+2 rows in set (0.00 sec)
mysql> select prod_name from products where prod_name regexp '[1-5] Ton';+--------------+| prod_name|+--------------+| .5 ton anvil || 1 ton anvil|| 2 ton anvil|+--------------+3 rows in set (0.02 sec)
mysql> select prod_name from products where prod_name regexp '[^1-3] Ton';+--------------+| prod_name|+--------------+| .5 ton anvil |+--------------+1 row in set (0.00 sec)
匹配特殊字符,必须用//为前导。
mysql> select prod_name from products where prod_name regexp '//.' ;+--------------+| prod_name|+--------------+| .5 ton anvil |+--------------+1 row in set (0.00 sec)
匹配字符类:
mysql> select prod_name from products where prod_name REGEXP '//([0-9] sticks?//)' order by prod_name;+----------------+| prod_name|+----------------+| TNT (1 stick)|| TNT (5 sticks) |+----------------+2 rows in set (0.05 sec)mysql> select prod_name from products where prod_name REGEXP '[[:digit:]]{4}' order by prod_name;+--------------+| prod_name|+--------------+| JetPack 1000 || JetPack 2000 |+--------------+2 rows in set (0.00 sec)
定位符用法:
mysql> select prod_name -> from products -> where prod_name REGEXP '^[0-9//.]' -> order by prod_name;+--------------+| prod_name |+--------------+| .5 ton anvil || 1 ton anvil|| 2 ton anvil|+--------------+3 rows in set (0.00 sec)
以上都是mysql正则表达式的用法。
内容总结
以上是互联网集市为您收集整理的mysql学习--mysql必知必会1_MySQL全部内容,希望文章能够帮你解决mysql学习--mysql必知必会1_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。