The most important SQL Commands used in our daily life

In this article, let us see the top most important SQL commands that we used in our daily life with simple examples.

SELECT Statement:

SELECT column1, column2, ... FROM table_name;
SELECT CountryID,CountryName from Country;

SELECT WHERE Clause:

SELECT column1, column2, ... FROM table_name WHERE condition;
SELECT CountryID,CountryName from Country WHERE CountryName='INDIA';

SELECT Condition with AND SYNTAX:

SELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...;
SELECT CountryID,CountryName from Country WHERE CountryName='INDIA' and Status='Active';

SELECT Condition WITH OR SYNTAX:

SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...;
SELECT CountryID,CountryName from Country WHERE CountryName='INDIA' or CountryName='JAPAN';

SELECT NOT Syntax:

SELECT column1, column2, ... FROM table_name WHERE NOT condition
SELECT CountryID,CountryName from Country WHERE Not CountryName='CHINA';

SELECT combining AND,OR and NOT Syntax:

SELECT * FROM Tablename WHERE column1='' AND (column2='' OR column2='');
SELECT CountryID,CountryName from Country WHERE status='Active' AND (CountryName='India' OR CountryName='Japan');

SELECT DISTINCT Syntax:

SELECT DISTINCT Column1,Column2 FROM Tablename WHERE column1='' AND (column2='' OR column2='');
SELECT DISTINCT CountryName from Country ;

SELECT ORDER BY Syntax:

SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC;
SELECT CountryID,CountryName from Country ORDER BY CountryName asc;