ab

Saturday, August 14, 2010

Basis Syntax of SQL

SQL Select

  1) SELECT * from table_name
       This syntax is used for selecting all the data from the table or for selecting all table.
    
                   Example : Select * from Employee

                         This will select all the data from the table Employee

  2) SELECT column_name(s)  FROM table_name
       This syntax is used for selecting particular column from the table .

                  Example  : Select Firstname,Lastname  from Employee

                      This will select only Column name (Firstname and Lastname)
                  
SQL Distinct
         In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.The DISTINCT keyword can be used to return only distinct (different) values.

  1) SELECT DISTINCT column_name(s) FROM table_name

            Example  : Select  DISTINCT Lastname  from Employee

                      This will select only distinct lastname from employee table


SQL Where
         Where is used  for condition in writing query
              Select Column_name from table_name WHERE column_name
            Example  : Select Firstname  from Employee where Lastname = Parker 

SQL And & Or
        
SQL Order By
SQL Insert
SQL Update
SQL Delete

1 comment:

adhitz