
- 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
Show column value twice in MySQL Select?
You can use concat(). Let us first create a table −
mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.73 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(200); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(200); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(200); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.30 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Value | +-------+ | 100 | | 200 | | 100 | | 200 | | 200 | | 100 | +-------+ 6 rows in set (0.00 sec)
Following is the query to display column value twice in MySQL −
mysql> select concat(Value,'~',Value) from DemoTable group by Value;
This will produce the following output −
+-------------------------+ | concat(Value,'~',Value) | +-------------------------+ | 100~100 | | 200~200 | +-------------------------+ 2 rows in set (0.00 sec)
- Related Articles
- MySQL SELECT to sum a column value with previous value
- Perform multiplication in SELECT depending on column value in MySQL?
- Select a specific value between two column values in MySQL?
- How to select the maximum value of a column in MySQL?
- Select minimum row value from a column with corresponding duplicate column values in MySQL
- How to select distinct value from one MySQL column only?
- MySQL query to select column where value = one or value = two, value = three, etc?
- MySQL procedure to display a “select” statement twice
- How to select row when column must satisfy multiple value in MySQL?
- Select from another column if selected value is '0' in MySQL?
- Combine SELECT & SHOW command results in MySQL?
- Select data and set value to boolean based on timestamp column in MySQL
- MySQL query to select rows where column value is only 0, group by another column?
- MySQL query to select the nth highest value in a column by skipping values
- Select nth highest value in MySQL

Advertisements