Advanced SQL queries
By following this recipe, you will learn how to use advanced SQL statements such as INNER
JOIN
, COUNT
, LIKE
, and DISTINCT
.
How to do it…
You can do a lot more than just perform simple queries on the SQL database. Let’s follow these steps to learn how:
- We need to add a few tables to our database before we can dive into the programming part. Open your SQLiteStudio. We need several tables for this example to work:

Figure 12.24 – Additional tables that we need to create for this example
- I will show you the structure of each of the tables required for this project and the dummy data inserted into the tables for testing. The first table is called
branch
, which is used to store the IDs and names of different branches of the dummy company:

Figure 12.25 – The branch table
- Secondly, we have the
department
table, which stores the IDs and names of different...