DataScienceLearn

8

Lessons

2

Videos

All

Skill Level

4 Hours

Duration

English

Language

Set Up & Introduction

In order to get started, make sure you have your environment set up. To do this, I recommend referencing these links:

  • You can download MySQL here.
  • One free interface I find very useful in writing SQL commands is PopSQL. Which you can download here.

Before we dive into writing SQL queries, it’s important to understand what SQL and MySQL are. SQL (Structured Query Language) represents the syntax used in manipulating relational databases, whereas MySQL is a RDBMS (Relational Database Management System). In other words, MySQL uses Structured Query Language to manipulate databases.

Shown below are two tables within a database. The table on the left shows the players trying out for sports teams while the table on the right shows the coaches for each sport.

SQL Database Tables

Completing this course will help you:

Who is the course for?

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu orci faucibus orci malesuada semper eget non tellus. Cras sed dignissim purus. Mauris varius neque leo, eu pellentesque justo venenatis et. Sed ultricies risus non turpis tempus, nec consectetur nulla suscipit.

Learning Path

Before we dive into writing SQL queries, it’s important to understand what SQL and MySQL are. SQL (Structured Query Language) represents the syntax used in manipulating relational databases, whereas MySQL is a RDBMS (Relational Database Management System). In other words, MySQL uses Structured Query Language to manipulate databases.

“Querying” a database is another way of saying you want to “retrieve information from” a database. SQL queries make use of a powerful command called SELECT, it allows us to retrieve specific information from our database. 

Video 48 Min  + 2 Min read to complete

The SELECT command is where we put the attributes we’re hoping to retrieve, the FROM command is used to signify which table we plan on selecting our attributes from, the * means “all”, and a WHERE command is used to provide a condition to determine which specific entries from those columns we hope to retrieve. Here’s an example of one of these queries.

Video 48 Min  + 2 Min read to complete

Sometimes we’re interested in querying data by categories or groups. To do this, we can make use of the GROUP BY command. Let’s say we were interested in the number of players for each sport. We would have to count the number of players grouped by Sport. In this example, we ordered the derived table in reverse-alphabetical order.

Unions and joins are incredibly useful in querying data from tables that can be combined. A UNION is an easy way to combine multiple SELECT statements. Here’s an example.

 

Sometimes we may need to write more complex queries and make use of nested queries. A nested query, sometimes called a subquery, is a SELECT statement within another SELECT clause. You can think of it as a query that’s based on another query. We’ll start off with a simple example. Let’s say we wanted a list of players with the same name as a coach. We could this simply by:

Ready to get Started?

More Courses

You might also be interested in these courses

Course 4

Data Modeling

Even though modeling data is extremely important, it's important to understand that a majority of your time will be spent cleaning and exploring your data and thus, should be practiced heavily. In this series, we'll go over some commonly used models, how they work, how to implement them, and when to use them. Feel free to use your own datasets when following along.

Data Modeling

Click to View Course
View Course

Course 3

Data Exploration

Lorem ipsum dolor sit amet, consectetur adipiscing elit. aulla sit amet magna sodales, interdum tortor etlert of dictum mauris loean ultricies lectus quis gravida urna interdum quam bibend.

Data Exploration

Click to View Course
View Course