Make delicious recipes!

Introduction to SQL

SQL stands for Structured Query Language.
It is the standard for interaction with the databases.
SQL features an English-like syntax which is easy to learn and allows complex query formation by feeding results of one query into another.

Some features of SQL are:
  1. Case-insensitive: So 'People', 'PEOPLE' and 'peopPle' are same in SQL.
  2. Nested queries are allowed. So one query can contain several subqueries which can also contain more subqueries.
  3. Allows specification of relations like foreign-key, primary-key, composite-key to preserve data integrity.

Some examples of the SQL syntax:

	id INT,
	age INT,
	first_name VARCHAR(50),
	last_name VARCHAR(50),
	birthday DATE NOT NULL,

/* Schema of a table can be modified after creation */

/* Data is read by 'Select' queries as follows */
Select * from people where age >= 30;
Select * from people where age between 30 and 50;
Select * from people where age > 30 and first_name = 'Bob';

/* Queried data can be sorted by making use of the 'Order by' clause */
Select first_name, age from people order by age desc;

/* Data can be grouped on any column. For example: */
Select age, count(*) from people group by age;
/* This query returns two columns per row. */
/* First column in each row will be age and second column would be the number of people having that age. */

/* A single query can have subqueries as expressions. For example: */
/* This query returns name and age of all the people whose age equals the average age of people in the table. */
Select first_name as fname, last_name as lname, age from people where age = (Select avg(age) from people)

/* Unwanted tables can be deleted easily */
Drop table people; 

Like us on Facebook to remain in touch
with the latest in technology and tutorials!

Got a thought to share or found a
bug in the code?
We'd love to hear from you:

Email: (Your email is not shared with anybody)

Facebook comments:

Site Owner: Sachin Goyal