All right.
So as I mentioned, we want to have the same data set, the same table, the same rows, so that we
get the same results.
Throughout this section, we're going to be working with a very simple books data set where a bookshop,
a bookstore, and there's a file that I'd like you to download attached to this video.
It's called Book Data or Books Data SQL.
It looks like this right here.
So I've actually opened it inside of SQL Workbench or you could do it inside of DB gate, or you don't
even have to open it at all.
But I want to show two options for getting this into a database for actually running this.
So what I'm going to do is start by making a new database.
So I'll call this.
How about just book shop?
Great.
Let's use that database here.
Book shop.
And of course, you could.
Oops, I didn't need to do use database.
It's just use bookshop.
We could do this all from within SQL Workbench or something like that.
It doesn't matter.
But what I'm going to do is refresh over here.
The first way I'll show you to run this is the simplest, which is just to click run here and make sure
we're using our bookshop database.
So just double click over here and now I'm going to run this script.
And if I head over here, select star from books, we should see our books data.
It doesn't print out nicely when my font is so zoomed in so that you guys can read it, but it's all
there.
Let's describe books as well.
So that's one option.
Let's just talk about this data briefly, right?
We've got a book ID, which is a primary key auto increment.
It's an integer.
Then we have title author, first name, author, last name.
Those are all text or VAR card fields 100 characters.
And then we have the release here, the quantity we have in stock and the length in pages of each book.
And then we have what, 16 books that we've inserted based off of this file that I gave you.
So that's one option.
And remember, you could do all of this from within a SQL workbench or DB gate or any competitor or
competing tool.
It's just a pain for me to show the results in here because you know, it's so tiny I can't increase
this font size, whereas here I can get something really immediate and obvious.
Now another option for running a file is instead of opening it directly in a gooey and then running
it from that gooey, what we can do is run the file from the command line.
So I'm actually going to drop that table drop table books.
I'm going to recreate it in just a moment.
So now we have notebooks, and this file that I gave you is called Book Data SQL, and we have a special
command we can run from within the MySQL shell called Source.
Now, I warned you right now, if you don't know how to navigate in your terminal, if you don't know
how to use LZ and CD, then this is not worth your time because you can just use the gooey and it works
very, very easily.
Right?
That was like one click.
That's all we had to do.
But if you are using the command line and you're comfortable with it, you can use this command.
So I'm actually going to leave my SQL just for a moment.
If I can remember, quit.
I have the file right here.
I put it in this folder.
It was in my downloads, I believe.
Yeah.
So I'm going to go back into that folder.
My SQL.
Whoops.
What did I call it?
My SQL course, I think.
There it is.
Just to show you, I navigate where this file is, and then I'll start up my SQL.
Dash you route.
Dash P for password.
I'll put in my password.
This is all recap, except I spelled my password wrong.
Of course.
And now I'm in here, and now I can source that file.
But there's going to be a problem.
Book data SQL.
The problem is that I'm not using a database, so I have to tell my SQL what database to use.
And this is, if I do a select database, we'll see.
I'm not using a database.
It's set to null, meaning the lack of a value.
There is no current database.
So I already made a database called Book Shop previously, but if you didn't have that yet, you could
create DB or create database bookshop or something like that.
I'll just use bookshop now.
Bookshop has nothing in it.
If I look at the tables, it's empty.
But now I can run my source command book, data SQL, and it created a new table and 16 rows.
If I describe books, there it is.
If I select star from books, it's going to be ugly.
But 16 rows.
So if you are not comfortable using and navigating via the command line, don't bother worrying about
any of what I just showed you.
It's way easier for most people to open up a script in one of these gooey tools and then run it from
there.
The only thing is you have to make sure to create the database first and use the right database.
Because my script that I give you only says to make a table.
It doesn't say what database to use or to create a database.
And I didn't show this, but the way I opened this in here, I actually dragged the file into the graphical
editor.
But you can also just click that little folder and then navigate to the file and open it.
And that's really all there is to it.
We now have our data set loaded.
Let's move on with all these string functions, except we're only covering a handful, but let's move
on to talk about them.