Here I am posting some simple SQL commands. My intention is not to introduce SQL commands to the reader or make her an expert. I know these clauses are so simple & easy to remember but still I made this post so that you can do a quick revision before attending an interview.

Select command

For specifying the data which need to be displayed from a table.

Syntax:

SELECT * from tablename

SELECT columnname1, columnname2, … FROM tablename

SELECT DISTINCT Statement

For displaying distinct values within the selection.

Syntax:

SELECT DISTINCT colunmnname FROM tablename

SELECT with WHERE

For selecting some values from a table satisfying a particular condition

Syntax:

SELECT colunmnname FROM tablename WHERE {condition}

Some examples where different conditions are used in combination with SELECT.

SELECT colunmnname FROM tablename WHERE columnname1=‘value1’ AND Columnname2=’value2’

SELECT colunmnname FROM tablename WHERE columnname1=‘value1’ OR columnname2=’value2’

SELECT colunmnname FROM tablename WHERE columnname1=‘value1’ AND (columnname2=’value2’ OR columnname2=’value3’)