You should have created a Google Cloud account, installed MySQL Workbench and made a connection to your database. In this lesson we will practice querying data.
- Open MySQL Workbench
-
Make sure you've selected the "admin" database
-
Create a new query tab
- Click the button on the top left that has a SQL file with a "plus" icon on it
-
Click the folder icon in your query tab to open a new file
-
Select the "initialize.sql" script that lives in this repo
-
Click the lightning bolt icon to run the query
-
If you refresh your schemas you should see a "users" table
We are going to run a couple SQL queries and put the answers in the "Query Responses" section of this README. The query instructions are intentionally written in plain english. It's up to you to translate that in a SELECT statement.
-
Select all fields from users where the city equals Chicago
-
Select the "state" field for users with a first name of "Glory"
-
Select all fields from users who's phone1 starts with "773"
- How many rows were returned: - There were a total of 7 rows returned.
- First name of the first user: - The first name of the first user is Mitsue
- How many rows were returned:
- There were 2 rows
- What states do they live in:
- MD and TX
- How many rows were returned:
- 6 rows returned
- What's the last email on the list: [email protected]
Think about how this data is laid out. Feel free to look in the initialize.sql file to see the raw data. Do you think it would be easier or harder to search through this data manually or using SQL? What about when the dataset gets larger?