Get the App
SLTechnology News&Howtos  ›  Database  › 

How does MySQL recognize whether there are Chinese characters

Shulou Source: shulou.com Published: 2022-05-31 15:59:56 10月04日 Update

This article mainly introduces MySQL how to identify whether there are Chinese characters, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

1) use the formal expression regexp "[u0391-uFFE5]"

2) use length and char_length

[@ more@]

Drop table t1

Create table T1 (id varchar) default charset=utf8

Insert into T1 values ('Chinese'), ('sdalfkj')

1) use the formal expression regexp "[u0391-uFFE5]"

Root@127.0.0.1: test 21:55:33 > select id, id regexp "[u0391-uFFE5] [u0391-uFFE5]" from T1

+-+

| | id | id regexp "[u0391-uFFE5] [u0391-uFFE5]" |

+-+

| | Chinese | 0 | |

| | sdalfkj | 1 | |

+-+

2 rows in set (0.01sec)

2) use length and char_length

Root@127.0.0.1: test 23:33:13 > select id,length (id), char_length (id) from T1

+-+

| | id | length (id) | char_length (id) | |

+-+

| | Chinese | 6 | 2 | |

| | sdalfkj | 7 | 7 |

+-+

2 rows in set (0.00 sec)

Thank you for reading this article carefully. I hope the article "how to recognize Chinese characters in MySQL" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles Chinese characters there are Chinese expressions values interests at the same time more friends knowledge editing industry information information channels channels references learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia Shulou Tech Info MySQL Xiaomi