SQL Basics

Introduction to SQL -
  • SQL stands for Structured Query Language.
  • SQL is an ANSI (American National Standards Institute) standard.
  • SQL is the standard language for RDBMS [Relational Database Management Systems].
  • SQL is used to communicate with a Database.
  •  With the use of SQL we can perform tasks like accessing and manipulating data stored in a Database Management System. 

Elements of SQL -
  • Clauses - Clauses are the components constituting the SQL statements and queries
  • Expressions - Expressions can produce scalar values or tables consisting of columns and rows of data
  • Predicates - Predicates specify the conditions used to limit the effects of statements & queries or to change the program flow
  • Queries - Queries retrieve the data based on a specific criteria
  • Statements - With SQL statements one can create, add, or modify data.


Basic SQL Queries - 


1. SELECT


SELECT * FROM TableName 

SELECT ColumnName(s)
FROM TableName


2. ORDER BY

SELECT ColumnName(s)
FROM TableName
ORDER BY ColumnName(s) ASC/DESC



3. SELECT DISTINCT


SELECT DISTINCT ColumnName(s)
FROM TableName


4. WHERE
 
SELECT ColumnName(s)
FROM TableName
WHERE ColumnName Operator Value


5. AND

SELECT * FROM TableName
WHERE 
Column1=Value
AND 

Column2=Value

6. OR

SELECT * FROM TableName
WHERE 
Column1=Value
OR

Column2=Value

6.ORDER BY

SELECT ColumnName(s)
FROM TableName
ORDER BY ColumnName(s) ASC/DESC


7. INSERT INTO 

INSERT INTO TableName (Column1, Column2, ...)
VALUES (Value1, Value2, ...)


8. UPDATE 

UPDATE TableName
SET Column1=value, Column2=value2, ...
WHERE Column=Value


9. DELETE 

DELETE FROM TableName
WHERE Column=Value

    Protected by Copyscape Plagiarism Check