
- 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
Find specific records which has whitespace on the second place in MySQL
For this, use SUBSTR() as in the below syntax −
select * from yourTableName where substr(yourColumnName, 2, 1 ) = ' ';
Let us first create a table −
mysql> create table DemoTable1365 -> ( -> Value varchar(20) -> ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1365 values('9756757474'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1365 values('3 45322333'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1365 values('8974646363'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1365 values('9 566363622'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1365;
This will produce the following output −
+-------------+ | Value | +-------------+ | 9756757474 | | 3 45322333 | | 8974646363 | | 9 566363622 | +-------------+ 4 rows in set (0.00 sec)
Here is the query to find the specific records in the table which has white space only on the second place like “3 4532” −
mysql> select * from DemoTable1365 -> where substr(Value, 2, 1 ) = ' ';
This will produce the following output −
+-------------+ | Value | +-------------+ | 3 45322333 | | 9 566363622 | +-------------+ 2 rows in set (0.00 sec)
- Related Articles
- MySQL query to place a specific record on the top
- Get MySQL DISTINCT to work correctly if the records contain whitespace?
- Find records on or after a specific date in MongoDB?
- MySQL query for grouping and summing the values based on specific records
- Find records with a specific last digit in column with MySQL
- MySQL to fetch records based on a specific month and year?
- How to sum selected column values based on specific month records in MySQL?
- Find specific records from a column with comma separated values in MySQL
- Find out the records of students with more than a specific score in MySQL?
- How to place a thousand separator in MySQL records?
- How to order records by a column in MySQL and place empty records at the end?
- Fetch records containing a specific character twice in MySQL
- Fetch ordered records after a specific limit in MySQL
- How to ignore specific records and add remaining corresponding records (numbers) in MySQL?
- Count the occurrences of specific records (duplicate) in one MySQL query

Advertisements