最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

mysql正則表達(dá)式使用實(shí)例

標(biāo)簽:
MySQL

Summary: in this tutorial, you will learn how to use MySQL regular expression with the SELECT statement to query data based on complex patterns.

Regular expression is a powerful tool that gives you a concise and flexible way to identify strings of text e.g., characters, words…etc based on patterns. For example, you can use regular expressions to search for email, IP address, phone number, social security number or anything that has specific pattern.

Regular expression is also known as regex. Regular expression uses its own syntax that can be interpreted by a regular expression processor. Regular expression is widely used in almost platforms from programming languages to databases including MySQL.

MySQL supports regular expression in the SQL statements, which you can search for strings of text by using special operator called REGEXP.  The following demonstrates the syntax of the REGEXP operator in the WHERE clause:

SELECT column_list  FROM table_name  WHERE column REGEXP pattern

The advantage of using regular expression is that you are not only limited to search for a string based on a fixed pattern like MySQL LIKE operator but also your own patterns.

The disadvantage of using regular expression is that it is quite difficult to understand and maintain such a complicated pattern. Therefore you should describe the meaning of regular expressions in the comments when using it in SQL statements. In some cases, the performance of data retrieval is decreased if you use complicated patterns in regular expression.

MySQL regular expression example

Let’s take a look at an example of using regular expressions in MySQL.

Suppose you want to find out employee whose last name starts with character M, B or T. You can use a regular expression in the SELECT statement as follows:

SELECT lastname, firstname  FROM employees WHERE lastname REGEXP  '^(M|B|T)';

mysql regular expression
The pattern allows you to find employee whose last name starts with character M, B or T.

  • The character ^ means to match from the beginning of the string.

  • The character | means to search for alternatives if one fails to match.

In this tutorial, you have learned how to query data from database table using MySQL regular expressions

Related Tutorials

原文链接:http://outofmemory.cn/mysql/tips/mysql-regular-expression-regexp

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消