![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
What does parenthesis mean in MySQL SELECT (COLNAME)?
The SELECT(COLNAME) means, we are creating an alias for that column. Let us see an example and create a table −
mysql> create table DemoTable865( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.77 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable865 values('Chris','Brown'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable865 values('Adam','Smith'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable865 values('David','Miller'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable865 values('Carol','Taylor'); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable865;
This will produce the following output −
+-----------+----------+ | FirstName | LastName | +-----------+----------+ | Chris | Brown | | Adam | Smith | | David | Miller | | Carol | Taylor | +-----------+----------+ 4 rows in set (0.00 sec)
Here, we are creating an alias for the column with SELECT (COLNAME) MySQL −
mysql> select (FirstName) StudentFirstName,(LastName) StudentLastName from DemoTable865;
This will produce the following output −
+------------------+-----------------+ | StudentFirstName | StudentLastName | +------------------+-----------------+ | Chris | Brown | | Adam | Smith | | David | Miller | | Carol | Taylor | +------------------+-----------------+ 4 rows in set (0.00 sec)
Advertisements