SQL select statement

      No Comments on SQL select statement

Some of the most used SQL statements

  • SELECT – extracts data from a database
  • UPDATE – updates data in a database
  • DELETE – deletes data from a database
  • INSERT INTO – inserts new data into a database
  • CREATE DATABASE – creates a new database
  • ALTER DATABASE – modifies a database
  • CREATE TABLE – creates a new table
  • ALTER TABLE – modifies a table
  • DROP TABLE – deletes a table
  • CREATE INDEX – creates an index (search key)
  • DROP INDEX – deletes an index

SQL select statement

The select statement in sql is used to select or extract data from a database.
The result is some rows from the table.
Syntax:

SELECT * from table_name;
OR
SELECT column_name,column_name from table_name;

Example:

Consider a sample database-Customer table

C.idC.nameC.contactC.address
123eed3Ramesh987654321#12,sec-4 mohali
aa22103Tarun987650000#12,sec-14 b chd
00146hhSia812300912#212,sec-86 panchukula
144dcv4Rahul700912366#001,sec-19 c chd

1.SELECT * from Customer;
RESULT:This query results all rows from table Customer.

C.idC.nameC.contactC.address
123eed3Ramesh987654321#12,sec-4 mohali
aa22103Tarun987650000#12,sec-14 b chd
00146hhSia812300912#212,sec-86 panchukula
144dcv4Rahul700912366#001,sec-19 c chd

2.SELECT c.id,c.name from Customer;
RESULT:This query results two columns that are named, from the table.

Consider a sample database-Customer table

C.idC.name
123eed3Ramesh
aa22103Tarun
00146hhSia
144dcv4Rahul

Leave a Reply

Your email address will not be published. Required fields are marked *