

- 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
MySQL select only a single value from 5 similar values?
Let us first create a table −
mysql> create table DemoTable800 ( Value int ); Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command. Here, we have inserted 5 similar values −
mysql> insert into DemoTable800 values(10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable800 values(10); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable800 values(10); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable800 values(10); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable800 values(10); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable800;
This will produce the following output -
+-------+ | Value | +-------+ | 10 | | 10 | | 10 | | 10 | | 10 | +-------+ 5 rows in set (0.00 sec)
Following is the query to select only a single value from 5 similar values −
mysql> select distinct Value from DemoTable800
This will produce the following output -
+-------+ | Value | +-------+ | 10 | +-------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- Get only a single value from a specific MySQL row?
- Update only a single value from a MySQL table where select from same table ordered in descending order?
- Select a value from MySQL database only if it exists only once from a column with duplicate and non-duplicate values
- Update only a single column value in MySQL
- Updating only a single column value in MySQL?
- Select the minimum value from the maximum values of two tables with a single MySQL query?
- How to select distinct value from one MySQL column only?
- Sum values in MySQL from similar day records
- How to select only non - numeric values from varchar column in MySQL?
- MySQL SELECT from two tables with a single query
- Select distinct values from three columns and display in a single column with MySQL
- Can we set a single value in MySQL SELECT IN()?
- Select only 5 random rows in the last 50 entries With MySQL?
- Decrement only a single value in MongoDB?
- Return only a single row from duplicate rows with MySQL
Advertisements