Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn SQL using MySQL in One Day and Learn It Well

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

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781836205678
Pages 121 pages
Edition 1st Edition
Languages
Author (1):
Jamie Chan Jamie Chan
Profile icon Jamie Chan

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}