Beginners Guide to SQL – SQL Syntax

(SQL Tutorials for Citizen Data Scientist)

SQL Syntax

The syntax of SQL is governed by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO).

SQL Statements

SQL statements are very simple and straightforward like plain English but with specific syntax.

An SQL statement is composed of a sequence of keywords, identifiers, etc. terminated by a semicolon (;). Here is an example of a valid SQL statement.


SELECT emp_name, hire_date, salary FROM employees WHERE salary > 5000;

For better readability you can also write the same statement, as follow:


SELECT emp_name, hire_date, salary 
FROM employees 
WHERE salary > 5000;

Use semicolon at the end of an SQL statement — it terminates the statement or submits the statement to the database server. Some database management system has, however, no such requirement, but it is considered as a best practice to use it.

We’ll discuss each part of these statements in detail in upcoming chapters.

Note: Any number of line breaks may occur within a SQL statement, provided that any line break does not break off keywords, values, expression, etc.

Case Sensitivity in SQL

Consider another SQL statement that retrieves the records from employees table:


SELECT emp_name, hire_date, salary FROM employees;

The same statement can also be written, as follow:


select emp_name, hire_date, salary from employees;

SQL keywords are case-insensitive that means SELECT is same as select. But, the database and table names may case-sensitive depending on the operating system. In general, Unix or Linux platforms are case-sensitive, whereas Windows platforms aren’t.

Tip: It is recommended to write the SQL keywords in uppercase, to differentiate it from other text inside a SQL statement for a better understanding.

SQL Comments

A comment is simply a text that is ignored by the database engine. Comments can be used to provide a quick hint about the SQL statement.

SQL support single-line as well as multi-line comments. To write a single-line comment start the line with two consecutive hyphens (--). For example:


-- Select all the employees
SELECT * FROM employees;

However to write multi-line comments, start the comment with a slash followed by an asterisk (/*) and end the comment with an asterisk followed by a slash (*/), like this:


/* Select all the employees whose 
salary is greater than 5000 */
SELECT * FROM employees
WHERE salary > 5000;


Beginners Guide to SQL – SQL Syntax


Personal Career & Learning Guide for Data Analyst, Data Engineer and Data Scientist

Applied Machine Learning & Data Science Projects and Coding Recipes for Beginners

A list of FREE programming examples together with eTutorials & eBooks @ SETScholars

95% Discount on “Projects & Recipes, tutorials, ebooks”

Projects and Coding Recipes, eTutorials and eBooks: The best All-in-One resources for Data Analyst, Data Scientist, Machine Learning Engineer and Software Developer

Topics included: Classification, Clustering, Regression, Forecasting, Algorithms, Data Structures, Data Analytics & Data Science, Deep Learning, Machine Learning, Programming Languages and Software Tools & Packages.
(Discount is valid for limited time only)

Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.

Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners

Please do not waste your valuable time by watching videos, rather use end-to-end (Python and R) recipes from Professional Data Scientists to practice coding, and land the most demandable jobs in the fields of Predictive analytics & AI (Machine Learning and Data Science).

The objective is to guide the developers & analysts to “Learn how to Code” for Applied AI using end-to-end coding solutions, and unlock the world of opportunities!