Search

Sunday, 30 June 2019

SQL Syntax


For each instruction here; let's call it each command as SQL like commands. First we will list and explain the syntax of the each command and then use an example to let  you digest how the command is used. Once you have read all the materials on this topic, you will have a general understanding of the syntax of SQL. In addition, you will be able to use SQL correctly to get information from the database. The author's own experience is that although a thorough understanding of SQL is not possible overnight, it is not difficult to have a basic understanding of SQL. I hope that after reading this here, you will have the same idea. Add this website to "My Favorites" now so that you can come back later at any time which you do by pressing 'Ctrl+D' button on your keyboard.


If you are teaching a course about SQL or a database, you are welcome to connect to this website for assistance. In this article we will look at examples and discuss the core keywords and basic syntax of the SQL language. All SQL statement begin with one of the following keywords which generally command or instruct SQL that what a user wants to do:

Keywords
Description
Select
The SELECT statement is used to select data from a database.

Distinct
The DISTINCT keyword is used to select distinct data from a database.

Where

The WHERE clause is used to select distinct records from a database

And/or

The AND Operators is used return result where both conditions satisfied.

OR
The OR Operators is used return result where one condition met. 

IN

The IN keyword is used to specify multiple values in the where clause.

Between

The BETWEEN Operator is used to select values in a range of data.

Like

The LIKE operator is used in a WHERE clause to search for a specific pattern of a data in a column.

Order By

The ORDER BY keyword is used to keyword is used to sort the result set in ascending or descending order.

Count

The COUNT function is used to count the number of rows that matches specified criteria.

Group By

The GROUP BY statement group same values into a group.

Having

The HAVING clause used instead of Where clause where aggregate functions used.

Create Table

The CREATE TABLE statement is used to create a new table in a database.

Drop Table

The DROP TABLE statement is used to drop an existing table in a database.

Truncate Table

The TRUNCATE TABLE statement is used to empty the table by truncating.

Insert Into

The INSERT INTO statement is used to insert new records in a table.
Update

The UPDATE statement is used to update data in one or more records in the table.

Delete From

The DELETE FROM statement is used to update data in one or more records in the table.































































This concludes our first part of the basic concepts of the main keywords used in SQL databases. In the next article, we will take a closer look at How to write basic SQL query using these keywords.                         
Below is a list of my favorite SQL books which I would recommend if you looking to enhance your knowledge on the SQL databases. 
                                                                                            


Below is my favourite Forums for SQL