Reader small image

You're reading from  Learn SQL using MySQL in One Day and Learn It Well

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781836205678
Edition1st Edition
Right arrow
Author (1)
Jamie Chan
Jamie Chan
author image
Jamie Chan

Jamie Chan is a tutor and freelance programmer with years of experience and a dedicated passion for sharing the joy of programming with as many people as possible. With seven bestselling programming books on Amazon, Jamie's publications stand out for their ability to break down complex concepts into simple terms. Additionally, each book includes complete projects at the end, enabling hands-on learning and a deep understanding of the concepts presented.
Read more about Jamie Chan

Right arrow

Filtering Columns

 

If we do not want to select all columns, we can list the columns we want.

 

Suppose we only want to select the em_name and gender columns from the employees table, we write

 

SELECT em_name, gender from employees;

 

The table below shows part of the results from this SELECT statement:

 

Image

 

Using Aliases

 

If you study the table above, you’ll notice that the table uses the column names (“em_name” and “gender”) as its column headings.

 

If we want the column heading to display a different name instead, we can use an alias for the column.

 

We do that using the AS keyword as shown in the following statement:

 

SELECT em_name AS `Employee Name`, gender AS Gender FROM employees;

 

In the statement above, note that we use the backtick character (normally found at the top left corner of the keyboard, together with the tilde ~ character) to enclose the first alias...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learn SQL using MySQL in One Day and Learn It Well
Published in: Apr 2024Publisher: PacktISBN-13: 9781836205678

Author (1)

author image
Jamie Chan

Jamie Chan is a tutor and freelance programmer with years of experience and a dedicated passion for sharing the joy of programming with as many people as possible. With seven bestselling programming books on Amazon, Jamie's publications stand out for their ability to break down complex concepts into simple terms. Additionally, each book includes complete projects at the end, enabling hands-on learning and a deep understanding of the concepts presented.
Read more about Jamie Chan