This is Session 3: Inserting and Viewing Values in SQL. If you haven’t viewed the previous article, I would highly recommend reading the following articles before you delve into this one to get the core steps down and this article builds upon the previous articles.
In the previous articles, I went over learning the basics of SQL and preparing to code. These articles included what you need to know to get started with SQL.
What this article won’t do is give you a deep understanding of all things SQL. It will give you just enough to get started so that you can leave the nest and start flying and experimenting on your own. I have broken down learning to code using these simple steps.
Step 1, Insert Values into the Table
In the previous article, I went over how to go about creating a database called BAKS_database and a table called training. In this Step, we will go over inserting values into the table:
Let’s insert the following values into the table:
class_name | price |
SQL Part 1 | 800 |
SQL Part 2 | 1200 |
SQL Part 3 | 200 |
SQL Part 4 | 350 |
SQL Part 5 | 150 |
You can insert values into the table using an INSERT INTO query:
INSERT INTO training (class_name, price) VALUES ('SQL Part 1',800), ('SQL Part 2',1200), ('SQL Part 3',200), ('SQL Part 4',350), ('SQL Part 5',150)
Step 2, In this step you will verify whether the values have been inserted into the table
Run the following SELECT query to verify that the values were inserted into the table:
SELECT * FROM training
You should then see the following results:
class_name | price |
SQL Part 1 | 800 |
SQL Part 2 | 1200 |
SQL Part 3 | 200 |
SQL Part 4 | 350 |
SQL Part 5 | 150 |
In the next tutorial, I will go over the following steps
- Creating Primary Keys
- Setting up Id’s
Thanks for reading. I would love to hear from you on how this is going for you.
To learn more about SQL outside of this post, click on the links below on recommended books on Amazon: