
- 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
How can we use CHAR_LENGTH() function with MySQL WHERE clause?
When CHAR_LENGTH() or CHARACTER_LENGTH() string function is used with WHERE clause, the output returns by it will depend upon the condition given in WHERE clause. For example, suppose we have a table named ‘Student’ and we want to get only those names having number of characters less than 6, then we can write following query −
mysql> Select * from Student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 | Harshit | Delhi | Commerce | | 20 | Gaurav | Jaipur | Computers | +------+---------+---------+-----------+ 4 rows in set (0.10 sec) mysql> Select Name, CHAR_LENGTH(Name) from student WHERE CHAR_LENGTH(Name)<6; +-------+-------------------+ | Name | CHAR_LENGTH(Name) | +-------+-------------------+ | Aarav | 5 | +-------+-------------------+ 1 row in set (0.00 sec)
- Related Articles
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use BIN() function with MySQL WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- How can we use MySQL INSTR() function with WHERE clause?
- How Can we use MySQL DISTINCT clause with WHERE and LIMIT clause?
- How can we use two columns with MySQL WHERE clause?
- How can I use SPACE() function with MySQL WHERE clause?
- How can we use MySQL REVERSE() function on column’s data along with WHERE clause?
- How can we use WHERE clause with MySQL INSERT INTO command?
- How can we use MySQL SUM() function with HAVING clause?
- Can we use the result of a SUM() function in MySQL WHERE clause
- Can we use WHERE clause inside MySQL CASE statement?
- How can MySQL REPLACE() function be used with WHERE clause?
- How can CONCAT() function be used with MySQL WHERE clause?
- How can CONCAT_WS() function be used with MySQL WHERE clause?

Advertisements