1. Interactive Guide to SQL

Vinayak Mathur
VLearn Together
Published in
5 min readJun 13, 2020

Data is the fuel on which the world is thriving right now, it seems, reasonable to focus on how we can leverage data and manipulate it according to our requirements but how do we do this?

There are a lot of follow up questions after this, the common ones being

How to store data? How to manage data? How to access it? and lots more but what is common in all of this

SQL.

Structured Query Language

It is omnipresent, almost impossible to see any businesses which are working with heaps of data without the use of SQL. So it is safe to say that if data is the fuel, then SQL is the driver. There are various offerings related to SQL, such as MySQL, NoSQL, PostgreSQL and SQLite. These are having similar structures and functioning with minor differences. You can work with any of them, and switch between them with ease. In terms of power, SQL is a great tool, it has seen significant growth across different profiles.

There is a common mistake that people do, they directly start with software packages and analytic tools, although this does not harm, you may have to pay with your precious time at a later stage, which you can invest in the early stages of your career path for better growth.

Do I need SQL?

If you find yourself on this list, then it is for you.

Data Scientist, Data Administrator, Database Architect, ETL Developer, BI Developer/Administrator, Data Analyst, Business Analyst, Data excites you or you are a Learner.

All of the professional roles require proper understanding and some experience with SQL.

Why do these roles need SQL?

SQL is important and is synonymous with data handling, apart from this SQL is spread across domains which makes it an important part of any data-focused organization or even data using businesses.

If you do not pick up SQL, then it would naturally be difficult for you to pick any other query language because they all have some similarities to SQL.

Now, that you know the importance of SQL lets get started.

Introduction to SQL:

The basic statements in SQL are,

Select: Select statement can help you get a particular column(s) from any table in the database.

In the first figure, you can see that we have used an *, this means that we are selecting all the data from the table. The next figures show the output and other variations with a select statement. We have used the same table for all the further statements so you can see the difference between the uses of various statements and understand them easily.

Figure 1
Figure 1: Output
Figure 2
Figure 2: Output

Where: It is a clause in the select statements which allows you to filter out data according to a certain condition. You can use this with different operators such as >,<, >=,<=, AND, OR, LIKE, NOT and BETWEEN.

A Select statement with where clause to find out details of those people whose age is more than 20.

Figure 3
Figure 3: Output

Select statement combining two conditions, age more than 20 and Id = 3.

Figure 4
Figure 4: Output

Select statement combining two conditions, age more than 20 or Id =5

Figure 5
Figure 5: Output

A Select statement using BETWEEN, carefully see that both 3 and 5 are included in the BETWEEN statement.

Figure 6
Figure 6: Output

Select statement with LIKE, it helps us in identifying those records which are specific, such as in our present example, we are searching for records in which names start with V, the % sign denotes one or more characters and _ sign denotes only one character. These characters are commonly referred to as wildcard characters.

Figure 7
Figure 7: Output

You can use any of the above statements with NOT to reverse the logic.

Figure 8
Figure 8: Output

We have taken the first step into SQL, by this time you should have a good idea about what SQL can do for you and if you should invest in it or not(The answer is Yes, you definitely should).

We can now identify some basic queries and use them along with operators for extracting data. Also, we have seen the where clause which is used to filter out information from the tables. This article is the first in the series of a quick guide to SQL, we have just touched the tip of SQL with this one, we will be moving on to more complex and useful data operations in SQL.

--

--