Advertisement

Selecting Columns from a Table

Selecting Columns from a Table Selecting Limited Columns
When you only want to retrieve a couple of columns from the table, all you have to mention is the list of column names separated by commas in the SELECT clause.

Exercise 4.01: Selecting Columns from a Table
The store manager wants to check the ProductCategoryId field of all the categories in PACKT_ONLINE_SHOP. They need you to retrieve the relevant columns, ProductCategoryId and ProductCategoryName. To retrieve this data from the table, we need to perform the following steps:

Open a new query window.
Switch to the PACKT_ONLINE_SHOP database:
use PACKT_ONLINE_SHOP;
Enter the following query:
SELECT ProductCategoryID, ProductCategoryName
FROM ProductCategories;
Note that the columns are displayed in the exact order they were mentioned in the SELECT statement. So, if we want to show the name of the category first followed by ID, we use the following statement:

SELECT ProductCategoryName, ProductCategoryID
FROM ProductCategories;
Thus, we can filter the columns that are displayed in the output just by including them in the SELECT statement.

-------------------------------------------------------------
Social Media Handles
**************************************************
Follow us on:
Website:
Instagram:
Twitter:
Facebook:
**************************************************

#viastudy

viastudy,viastudy.com,database,db,sql,sql server,mysql,imdurgesh.singh,imdurgeshsingh,erdurgeshsingh,programming,

Post a Comment

0 Comments