SQL SELECT Statement

0
23

sqltuts

The SELECT statement tells what is to be returned. ‘*’means all the columns from all tables in the from statement are to be returned.

 

Syntax:

 

  1. SELECT <field1>,<field2>
  2. FROM <table_name>;

 

For example, we have this table Employee:

Employee_id First_name Last_name sex
123 Mack Johnson male
124 Jack Obama male
125 King Khan male

 

Now, we want to select two columns Employee_id and First_name:

 

  1. SELECT Employee_id,First_name FROM Employee;

 

This would give the following result:

Employee_id First_name
123 Mack
124 Jack
125 King

 

  1. SELECT * FROM Employee;

The above command would display the whole table.

Facebook Comments
(Visited 29 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here