Thursday, August 21, 2014

SQL SELECT

The SELECT statement in SQL is used to select data from the database.

SQL SELECT Syntax

SELECT columnname
FROM tablename;

SELECT *
FROM tablename

SELECT *
FROM tablename
WHERE conditions

SQL SELECT Examples

Tablename = "employees"
ID No. Name Department  Gender  Age  Date Hired
1 John Smith Sales M 26 June 1, 2010
2 Jane Doe Manager F 30 December 1, 2006  
3 Mary Lincoln  Admin F 24 April 10, 2010

To Select all employees
SELECT * 
FROM employees

To Select the female employees
SELECT * 
FROM employees
WHERE Gender = "F"

To Select all employees and only name and department are needed
SELECT Name, Department
FROM employees

0 comments:

Post a Comment

 
Related Posts Plugin for WordPress, Blogger...