

- 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
Get the size of selected rows in MySQL
To get the size of selected rows, use CHAR_LENGTH(). Let us first create a table −
mysql> create table DemoTable1612 -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.87 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1612 values('David','Brown'); Query OK, 1 row affected (0.75 sec) mysql> insert into DemoTable1612 values('John','Smith'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1612 values('Bob','Taylor'); Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1612;
This will produce the following output −
+-----------+----------+ | FirstName | LastName | +-----------+----------+ | David | Brown | | John | Smith | | Bob | Taylor | +-----------+----------+ 3 rows in set (0.00 sec)
Following is the query to get the size of selected rows in MySQL −
mysql> select sum(char_length(FirstName)) from DemoTable1612 where LastName IN('Brown','Smith','Taylor');
This will produce the following output −
+-----------------------------+ | sum(char_length(FirstName)) | +-----------------------------+ | 12 | +-----------------------------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- Display multiple selected rows using MySQL IN()
- Get the sum of a column in all MySQL rows?
- How to get the size of the tables of a MySQL database?
- Get the count of only unique rows in a MySQL column?
- Get the number of rows in a particular table with MySQL
- Get at least x number of rows in MySQL?
- Get the size of the IdentityHashMap in Java
- Specify the size of the rows in a CSS grid layout
- Get rows with GROUP BY in MySQL?
- How to get selected Index of the Radio group in Android?
- How to get the index of selected option in Tkinter Combobox?
- Get total number of rows while using LIMIT in MySQL?
- Get the size of an ArrayList in Java
- Get the path of the file selected in the JFileChooser component with Java
- Get the size of the LabelValue Tuple in Java
Advertisements