Basic SQL Query Syntax

SELECT (attribute list)
FROM   (table list)
[WHERE (condition)]
[GROUP BY (grouping attributes)]
[HAVING (group condition)]
[ORDER BY (attribute list)] 

Note: The SELECT and FROM clauses are mandatory.

  1. The SELECT clause lists the attributes to be retrieved.
  2. The FROM Clause specifies all tables
  3. The WHERE clause specifies the conditions for the selection of records from these tables, including joint conditions.
  4. GROUP BY specifies grouping attributes
  5. HAVING specifies a condition for the retrieval of groups.

Various COUNT, SUM, MIN, MAX, and AVG can be in conjunction with grouping. ORDER BY specifies an order for displaying the result of a query.

SQL Full Form

SQL stands for Structured Query Language and is used to manage and manipulate relational databases. SQL provides a standardized way to interact with databases, allowing users to create, retrieve, update, and delete data efficiently. SQL commands are used to perform various operations on databases.

Similar Reads

What is SQL?

Structured Query Language (SQL) is a specialized programming language for managing relational database data. It allows users to store, manipulate, and retrieve data efficiently in databases like MySQL, SQL Server, Oracle, and more....

Basic SQL Query Syntax

SELECT (attribute list) FROM (table list) [WHERE (condition)] [GROUP BY (grouping attributes)] [HAVING (group condition)] [ORDER BY (attribute list)]...

SQL Characteristics

Tables, also called relations are represented by a name, not exceeding 20 characters in length. The table names as well as the column fields should have unique names. While the table definition, the field list is separated using commas, and each field name consists of a data type followed by a length attribute enclosed in brackets. SQL statements must end with a semicolon....

Advantages of using SQL

High performance. Easily compatible with most of the databases like MS Access, MS SQL server. Good flexibility in terms of the creation of new Data Base tables and deletion of redundant tables. Can handle large records and multiple transactions. Easily accessible in the form of an open-source programming language. High Security: Tables, procedures, and views can easily be protected using permissions Easy to learn and understand data...

Disadvantages of using SQL

Complex interface to understand and deal with it. The higher cost required to set up. It is a platform-dependent and compound-based language. Extra space is required for each record storage. Partial control is given to databases, due to hidden permissions....

Frequently Asked Questions on SQL

Is SQL case-sensitive?...