
- 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 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 Articles
- Update only a single value from a MySQL table where select from same table ordered in descending order?
- Get only a single value from a specific MySQL row?
- Select a value from MySQL database only if it exists only once from a column with duplicate and non-duplicate values
- Select the minimum value from the maximum values of two tables with a single MySQL\nquery?
- How to select distinct value from one MySQL column only?
- Updating only a single column value in MySQL?
- Update only a single column value in MySQL
- Select distinct values from three columns and display in a single column with MySQL
- How to select only non - numeric values from varchar column in MySQL?
- Can we set a single value in MySQL SELECT IN()?
- MySQL SELECT from two tables with a single query
- A single MySQL query to select value from first table and insert in the second?
- Sum values in MySQL from similar day records
- MySQL randomly select 2 values from column values?
- MySQL query to skip the duplicate and select only one from the duplicated values

Advertisements