knowledgediarybd.com

Your Virtual Knowledge Campus

SQL SELECT AND WHERE Statement

SQL Select and Where Statement  are two vital command in structural query language. Purpose of Select  Statement :SQL SELECT statement is used to select data from a database and with help of where command you can see whole table or a specific column.

SQ L SELECT Syntax:

Syntax 1: select column_name  from table_name and

Syntax 2:  select * from table_name

[ Note: SQL is not case sensitive and the use of asterisk (*)symbol  is a quick way for  selecting all columns of a table]

An SQ L SELECT Example:

The “teacher info2” table: TEACHER INFO Now we  select the content of the columns named   “FIRST_NAME” AND

“LAST_NAME from the above table. We use the following SELECT statement:

SELECT FIRST_NAME, MIDDLE_NAME FROM `teacher info2`

The result of the  above SQL query will look like below: SELET

An SQL SELECT * Example:

SELECT * FROM `teacher info2`

The result of above SQL query will look like this: after drop

SQL WHERE Clause:

In SQL WHERE clause is used to filter records.

Syntax SQL WHERE Clause:

select column_name  from  table_name  WHERE column_name equal some value

An SQL  WHERE Example:

The “teacher info2” table: after drop Now we select only the persons whose salary is “30000” from the above table. We use the following SELECT statement:

SELECT *FROM `teacher info2` WHERE LAST_NAME = 'SHOVON'

The result of the above SQL query will look like this: where query

SELECT * FROM `teacher info` WHERE 1

Here, WHERE 1 means all time true that means when we will use  WHERE 1 then all of the record of a table will visible. The result of  SELECT * FROM `teacher info` WHERE 1  will look like this: after drop

More Example Of WHERE Clause :

In case of  text values:

This is correct:
SELECT * FROM `teacher info2` WHERE FIRST_NAME='HEDAYETUL'
This is wrong:
SELECT * FROM `teacher info2` WHERE FIRST_NAME=HEDAYETUL

In case of  numeric values:

This is correct:
SELECT * FROM `teacher info` WHERE SALARY = '30000'
This is also correct:
SELECT * FROM `teacher info` WHERE SALARY =30000

Related Post or you may like:

  1. Introduction of Database & SQL

  2. Create Database & Table

  3. SQL Insert,Update & Delete

  4. SQL Primary,Unique & Foreign Key

  5. SQL Drop truncate and Alter

  6. SQL Order By& Group By

  7. SQL Like & Check Constrain

  8. Database Connection

knowledgediarybd.com © 2017
shares