SQL Syntax
PART 1 :
SQL is followed by an interesting group of rules and guidelines called Syntax. This tutorial gives you a quick start with SQL by listing all the basic SQL sentencing structures.
All SQL guidelines start standard one of the key witticisms like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all directions end standard a semicolon (;).
The point in addition to significant to note here is that SQL is unaware to the case, which means that SELECT and select have the same meaning in SQL directions. While MySQL makes the difference in table names. So if you work with MySQL, then you have to give table names as they exist in the database.
Some of the SQL commands in addition to important :
- SELECT : extracts data from a database
- UPDATE : Updates database data
- DELETE : deletes data from a database
- INSERT INTO : inserts new data into a database
- CREATE DATABASE : creates a new database
- ALTER DATABASE : changes a database
- CREATE TABLE : creates a new table
- ALTER TABLE : changes a table
- DROP TABLE : removes a table
- CREATE INDEX : creates a queue (search key)
- DROP INDEX : removes a queue
SQL SELECT Statement :
A database contains in addition to often one or more tables. Each scene is identified as standard a name (e.g. "Customers" or "Orders"). Tables contain records (lines) with data.
In this tutorial, we will use the well-known Northwind sample database (included in MS Access and MS SQL Server).
Most of the activities you need to do in a database are done with SQL directions.
SELECT column1, column2....columnN FROM table_name;
Example :
SELECT * FROM Customers;
SELECT CustomerID , Country FROM Customers;
SQL DISTINCT Clause :
SELECT DISTINCT column1, column2....columnN FROM table_name;
Settings or restraints :
Joints
Columns or calculations you want to retrieve.
Tables
The tables from which you want to retrieve records. There must be at least one table listed in the PROvisoFROM.
Where conditions
Optional. The conditions that must be met for the files to be selected.
Note :
When a single joint is provided in the DISTINCT provision, the query returns the unique values of that joint.
When multiple joints are provided in the DISTINCT statement, the query recovers unique combinations for the listed joints.
In SQL, the DISTINCT provision does not ignore null values. So when you use the DISTINCT condition in your SQL guidance, your set of results will include NULL as a separate value.
Example :
SELECT DISTINCT state FROM suppliers;
SELECT DISTINCT city, state,....... FROM suppliers;
SELECT DISTINCT * FROM suppliers;
SQL WHERE Clause :
Syntax
The basic syntax of the SELECT statement with the WHERE statement is shown below.
SELECT column1, column2....columnN FROM table_name WHERE CONDITION;
SELECT * FROM ARTICLE WHERE PRICE > 200 ;
SELECT Name FROM ARTICLE WHERE PRICE > 200 ;
1 Comments
Thanks for your information. very good article.
ReplyDeleteBest ServiceNow Online Training in Hyderabad
ServiceNow Training