- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create Tab Delimited Select statement in MySQL?
To create a tab delimited select statement, you can use CONCAT() function from MySQL. Following is the syntax:
select concat(yourColumnName1,"\t",yourColumnName2) AS anyAliasName from yourTableName;
Let us first create a table:
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.81 sec)
Following is the query to insert records in the table using insert command:
mysql> insert into DemoTable(FirstName,LastName) values('John','Smith'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(FirstName,LastName) values('Carol','Taylor'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(FirstName,LastName) values('John','Doe'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(FirstName,LastName) values('David','Miller'); Query OK, 1 row affected (0.12 sec)
Following is the query to display records from the table using select command:
mysql> select *from DemoTable;
This will produce the following output
+----+-----------+----------+ | Id | FirstName | LastName | +----+-----------+----------+ | 1 | John | Smith | | 2 | Carol | Taylor | | 3 | John | Doe | | 4 | David | Miller | +----+-----------+----------+ 4 rows in set (0.00 sec)
Following is the query to create tab delimited select statement:
mysql> select concat(FirstName,"\t",LastName) AS Tab_Delimited_Demo from DemoTable;
This will produce the following output:
+--------------------+ | Tab_Delimited_Demo | +--------------------+ | John Smith | | Carol Taylor | | John Doe | | David Miller | +--------------------+ 4 rows in set (0.00 sec)
- Related Articles
- How to create a temporary MySQL table in a SELECT statement without a separate CREATE TABLE?
- How to use NULL in MySQL SELECT statement?
- MySQL select distinct rows into a comma delimited list column?
- How to use a select statement while updating in MySQL?
- How to select return value from MySQL prepared statement?
- MySQL case statement inside a select statement?
- How to use the CAST function in a MySQL SELECT statement?
- How to call a stored procedure using select statement in MySQL?
- IF() function in a MySQL Select statement?
- How to use prepared statement for select query in Java with MySQL?
- MySQL procedure to display a “select” statement twice
- MySQL SELECT IF statement with OR?
- How to Create a Tab Layout in Android App?
- MySQL query to generate row index (rank) in SELECT statement?
- Change value from 1 to Y in MySQL Select Statement?

Advertisements