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)