

- 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 count of how many times a string appears in a MySQL column?
Let us first create a table −
mysql> create table DemoTable704 (SubjectName text); Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable704 values('Introduction to MongoDB'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable704 values('Introduction to Java'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable704 values('Introduction to MongoDB'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable704 values('Introduction to C'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable704 values('Introduction to Spring and Hibernate'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable704;
This will produce the following output -
+--------------------------------------+ | SubjectName | +--------------------------------------+ | Introduction to MySQL | | Introduction to MongoDB | | Introduction to MySQL | | Introduction to Java | | Introduction to MongoDB | | Introduction to MySQL | | Introduction to C | | Introduction to Spring and Hibernate | +--------------------------------------+ 8 rows in set (0.00 sec)
Following is the query to get count of how many times string appears in column −
mysql> SELECT COUNT(*) from DemoTable704 WHERE SubjectName LIKE '%Introduction to MySQL%';
This will produce the following output -
+----------+ | COUNT(*) | +----------+ | 3 | +----------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- Count how many times the substring appears in the larger String in Java
- Count number of times value appears in particular column in MySQL?
- Program to find how many times a character appears in a string in PHP
- How can I get the number of times a specific word appears in a column with MySQL?
- Number of times a string appears in another JavaScript
- Counting how many times an item appears in a multidimensional array in JavaScript
- MySQL query to count the number of times a specific integer appears in a column for its corresponding value in another column
- Is it possible to combine 'DISTINCT' and 'COUNT' queries, so that I can see how many times each distinct value appears in a MySQL table column?
- How to get the count of a specific value in a column with MySQL?
- Get the count of only unique rows in a MySQL column?
- Python Program to Determine How Many Times a Given Letter Occurs in a String Recursively
- How to find string count of a particular id in a column using a MySQL query?
- How to get the count of each distinct value in a column in MySQL?
- Get count of values that only appear once in a MySQL column?
- Get the count of duplicate values from a single column in MySQL?
Advertisements