

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find capital letters with Regex in MySQL?
You can use REGEXP BINARY for this
select *from yourTableName where yourColumnName REGEXP BINARY '[A-Z]{2}';
Let us first create a table
mysql> create table FindCapitalLettrsDemo -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentFirstName varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('JOHN'); Query OK, 1 row affected (0.24 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('carol'); Query OK, 1 row affected (0.17 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('John'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from FindCapitalLettrsDemo;
The following is the output
+-----------+------------------+ | StudentId | StudentFirstName | +-----------+------------------+ | 1 | JOHN | | 2 | Carol | | 3 | bob | | 4 | carol | | 5 | John | +-----------+------------------+ 5 rows in set (0.00 sec)
Here is the query to find capital letters in MySQL
mysql> select *from FindCapitalLettrsDemo -> where StudentFirstName REGEXP BINARY '[A-Z]{2}';
The following is the output
+-----------+------------------+ | StudentId | StudentFirstName | +-----------+------------------+ | 1 | JOHN | +-----------+------------------+ 1 row in set (0.14 sec)
- Related Questions & Answers
- Regex in Python to put spaces between words starting with capital letters
- How to input letters in capital letters in an edit box in Selenium with python?
- c# Put spaces between words starting with capital letters
- How to set the font to be displayed in small capital letters with JavaScript?
- How to move all capital letters to the beginning of the string in JavaScript?
- Python regex to find sequences of one upper case letter followed by lower case letters
- Move string capital letters to front maintaining the relative order - JavaScript
- MySQL RegEx to find lines containing N semi-colons?
- MongoDB regex to display records whose first five letters are uppercase?
- How to change column names to capital letters from lower case or vice versa in R?
- MySQL query to count records that begin with specific letters
- How can we print all the capital letters of a given string in Java?
- JavaScript regex program to display name to be only numbers, letters and underscore.
- Delete last 4 letters in MySQL?
- How to convert python regex to java regex?
Advertisements