SQL - Series - BASIC Commands - SELECT, DISTINCT, WHERE, AND, OR, NOT

Some of the basic commands in SQL 

1. SELECT 

The SELECT Statement is used to select data from database

Syntax

SELECT COLUMN1, COLUMN2, ...

FROM TABLE_NAME;


2.DISTINCT

The SELECT DISTINCT is used to return only distinct (different) Values.

In many case our table will contain duplicate values and sometimes we need only distinct (different) values as result. In that case we can use DISTINCT Keyword 

Syntax

SELECT DISTINCT COLUMN1, COLUMN2, ...

FORM TABLE_NAME;


3.WHERE || AND  || OR || NOT

The WHERE Clause is used to Filter the records

It is used to extract only those records that fulfill a specified condition.

Along with relational operator =, >, <, >=, <=, <>

BETWEEN - Between a certain Range

LIKE - Search for a Pattern

IN - To Specify Multiple possible values for a column


Syntax

SELECT COLUMN1, COLUMN2, ...

FROM TABLE_NAME

WHERE CONDITION;


We can also use WHERE along with AND, OR and NOT operator as below


Syntax

SELECT COLUMN1, COLUMN2, ...

FORM TABLE_NAME

WHERE CONDITION1 OR/AND CONDITION2 OR/AND CONDITION3;


Syntax

SELECT COLUMN1, COLUMN2, ...

FORM TABLE_NAME

WHERE NOT CONDITION ;


Comments