fbpx

FROM

Let's return to our schoolhouse example from SELECT!

When we navigated to the Students page…

…we stated that we'd like to view data on the Students page. We could've chosen different pages...

...but instead of choosing to view data on Grades and/or Curriculum, we chose Students.

By choosing the Students page specifically, we performed a FROM statement. Out of all the pages in the teacher dashboard, we chose the page pertaining to students. In SQL terms...

FROM statements are used to state out of all the tables in a database, what specific table you'd like to access data from.

How to code a FROM

Here's the template for FROM statements:

FROM database_name.table_name;

We'll use this to apply FROM statement to our schoolhouse attendance scenario. As a starting point, let's go ahead and pull up our query we had started in SELECT, and plug in our FROM statement template!

SELECT *
FROM database_name.table_name;

Every SQL query must have a SELECT and FROM statement!

Now, let's say the schoolhouse named their database schoolhouse_db. We'd then place the following into our query.

SELECT first_name, last_name
FROM schoolhouse_db.table_name;

The table containing student information is called students. Therefore, we'll place the following into our query.

SELECT first_name, last_name
FROM schoolhouse_db.students;

And there you have it! When you execute this query, you'd get the following results:

Query Output

first_namelast_name
AndySherman
ShellyJohnson
MarthaSmith
DannyAlbert