
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to display all the fields that contain a capital letter?
To display all the fields that contain a capital letter, use the RLIKE that performs a pattern match of a string expression against a pattern.
Let us first create a table −
mysql> create table contains_capital_letterDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (1.42 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into contains_capital_letterDemo(Name) values('Larry'); Query OK, 1 row affected (0.17 sec) mysql> insert into contains_capital_letterDemo(Name) values('larry'); Query OK, 1 row affected (0.12 sec) mysql> insert into contains_capital_letterDemo(Name) values('john'); Query OK, 1 row affected (0.13 sec) mysql> insert into contains_capital_letterDemo(Name) values('JOHN'); Query OK, 1 row affected (0.36 sec) mysql> insert into contains_capital_letterDemo(Name) values('mike'); Query OK, 1 row affected (0.14 sec) mysql> insert into contains_capital_letterDemo(Name) values('Mike'); Query OK, 1 row affected (0.27 sec)
Following is the query to display all records from the table using select statement −
mysql> select * from contains_capital_letterDemo;
This will produce the following output −
+----+-------+ | Id | Name | +----+-------+ | 1 | Larry | | 2 | larry | | 3 | john | | 4 | JOHN | | 5 | mike | | 6 | Mike | +----+-------+ 6 rows in set (0.00 sec)
Following is the query to display all the fields that contain a capital letter −
mysql> select * from contains_capital_letterDemo WHERE CAST(Name AS BINARY) RLIKE '[A-Z]';
This will produce the following output −
+----+-------+ | Id | Name | +----+-------+ | 1 | Larry | | 4 | JOHN | | 6 | Mike | +----+-------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL query to select all fields beginning with a given number with next character a letter?
- MongoDB query to display all the fields value, except _id
- Display all fields of a table in MySQL?
- MySQL query to get a field value that does not contain empty spaces?
- MySQL query to update all records to capitalize only the first letter and set all others in lowercase
- How to search a word by capital or small letter in MySQL?
- MySQL query to display only the records that contains single word?
- How to display the bit(1) fields in MySQL?
- MySQL query to update different fields based on a condition?
- Find all the names beginning with the letter 'a' or ‘b’ or ‘c’ using MySQL query?
- MySQL query to display structure of a table
- MySQL query to get the length of all columns and display the result in a single new column?
- MongoDB query to display all the values excluding the id?
- Query in MySQL for string fields with a specific length?
- Get the count of two table fields in a single MySQL query?

Advertisements