
- 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 find a value appearing more than once?
Let us first create a table −
mysql> create table DemoTable -> ( -> value int -> ); Query OK, 0 rows affected (0.82 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.07 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-------+ | value | +-------+ | 10 | | 100 | | 20 | | 10 | | 30 | | 40 | | 20 | +-------+ 7 rows in set (0.00 sec)
Following is the query to find a value appearing more than once −
mysql> select *from DemoTable group by value having count(*) > 1;
Output
This will produce the following output −
+-------+ | value | +-------+ | 10 | | 20 | +-------+ 2 rows in set (0.00 sec)
- Related Articles
- MySQL Select where value exists more than once
- MySQL query to fetch date more recent than 14 days?
- Array elements that appear more than once?
- Element Appearing More Than 25% In Sorted Array in C++
- How to get a value more than a particular value from varchar column in MySQL?
- MySQL query to count where more than three columns values are true?
- MySQL query to add dots if string has more than 10 words?
- MySQL query to order rows with value greater than zero?
- addEventListener() not working more than once with a button in JavaScript?
- Insert more than one element at once in a C# List
- Array elements that appear more than once in C?
- How to delete fields with values more than a particular value in MySQL?
- Query to find Nth maximum value in MySQL
- MySQL query to include more than one column in a table that doesn't already exist
- MySQL query to replace a column value

Advertisements