Introduction to SQL

Siva
2 min readOct 18, 2020

SQL(Structured query language) is a programming language that is used to communicate with a relational database and perform several activities such as querying, retrieve data, etc from a database.

SQL basics

Some of the basic SQL commands are CREATE for creating a table, INSERT INTO to insert data into the table, SELECT command for selecting data according to the given condition from the database.

Advanced SQL queries

AND, OR commands are some conditional logics in SQL which returns true only if the condition is met. IN command specify allow you to specify multiple values in a WHERE clause or IN can also be used in place of multiple OR conditions.

HAVING is used in SQL because we cannot use aggregation in WHERE clause. HAVING allows us to specify the condition such that SELECT statement returns only those rows that met the condition.

CASE command is like if-else condition, it goes through multiple conditions and returns the value when the condition is satisfied.

Relational queries

JOIN command is used to combine rows from multiple tables based on the given condition and also the related column in the tables. This is mostly used when data is across multiple tables and is related to each other. Types of joins are INNER, OUTER, SELF, etc.

Modifying databases with SQL

Once you create a database there might be a situation where you want to update, delete the existing data. To do this, we have commands like UPDATE to update the information in a table, DELETE to delete the information in a table, ALTER to make any changes in the table.

Further learning in SQL

To move beyond querying, updating the database, try SQL for data analysis, try in different environments, learn more SQL across different relational databases, learn to design a database, principles of the database.

--

--