SQL SELECT Statement | Querying Data from Single Table

SQL SELECT Statement:SELECT‘ statement is the most widely used SQL command/query to retrieve data from database. Before we proceed with the SQL course, we have to know few generic terms which SQL follows below:

Points to be noted?

  1. The “” is the comment out command, if specified then it will not execute that line and skip to next line.
  2. Spaces, Tabs & Writing queries on same/next line will be ignored in SQL.
  3. If you are dealing with one particular data base and later start to query next data base, then you have to manually select the database or use this command “USE database_name;
  4. *” (Astri’s) is used to pull/get complete data from particular table.

SQL SELECT Statement

SELECT is used to get data from anywhere in the table or database. The select command has more widely used command with different clause and multiple kind of queries (E.g., Sub Queries).

— 1. The select statement can be used without any clause. If you run this below query, we will get the output with the data already present in it. We can use any number of data to print values in strings and numbers.

SELECT 1,2,3,4,5;
SQL SELECT Statement

— 2. If you see in the below query, I am using customer table to get all the data from customer. Note: The * cannot be used with database name, we have to use with any king of table name. “Customers” is the table name, and I am pulling all the data from customer table

SELECT *
FROM Customers;
SQL SELECT Statement

— 3. Now if you want to select multiple columns from table then you can just specify the column name with comma separated with it. Note: The column you specify the first after SQL SELECT statement will appear the first in the result output but will never impact the original database.

SQL SELECT Statement

— 4. We can use WHERE clause to get data for particular condition and also note the order of the clause must be in order wise. The clause must be in this static order (select >> from >> where >> order by), if not we will get syntax error. Click here!

SELECT *
FROM Customers
WHERE customer_id = 3
ORDER BY first_name;
SQL SELECT Statement

Watch Video!

Next Post>> #2.2) Select Clause (Single Table)

<< Previous Post #1.4) Restore SQL Sample Database

Vickey Rajpoot
Vickey Rajpoot

Hello there! I'm dedicated Microsoft Data & AI Engineer at LTIMindtree, where I thrive technology into actionable insights. Dive into my world by visiting my YouTube channel & Webiste, "Kingfisher Tech Tips".

Articles: 114

One comment

  1. IWIN68 – Home page to download IWIN68 club for APK/IOS, official online reward game portal giving away code 99K at iwin68-club.net. IWIN68 is the leading online prize exchange card game portal in Asia, with many attractive games including crabs, coin toss, Sic Bo, casino, sports,… https://iwin68-club.net/

Leave a Reply

Your email address will not be published. Required fields are marked *