All right.
So the next thing I always like to do is start off with some SQL as soon as possible, because the next
couple of videos after this are very much focused on talking about high level concepts like what is
equal, what is my SQL, how do they compare, what are other database types?
And then things like installation for Mac versus Windows and installing a graphical interface, installing
a command line client.
And then finally we can start writing code.
So I feel like it's a bit of a slog if we don't at least start with some basic SQL right away.
So that's what we're going to do here.
You're not going to learn all that much.
We're not going to talk about the syntax, but we're going to play around with it.
You don't have to install anything.
In fact, there is a link I'd like you to click.
You don't have to open the slides to get this link.
You can just find the link attached to this video as a resource.
It will take you to this web page full of lovely ads.
This is a website that allows us to run some basic SQL code in the browser, so we're going to install
my SQL locally.
It can do a lot more than we can do in the browser, but there's a database already set up here that
has some data in IT.
Customers and categories.
Employees order details, orders, product shippers, suppliers, and we can interact with that data
by writing some basic queries.
And that's the format.
That's how we work with SQL.
We write these queries, they might look like this or way longer, and then we execute them and we'll
get some results.
So if I click the Run SQL run SQL button, here are the results.
And this data is just dummy data that's in here.
I don't think it's real customer data, but you can see we are using a command called Select Star from
customers.
Again, we're not going to worry about what this all means, but if you read it, maybe you can figure
it out, right?
Select customers Where city is equal to London or country is equal to UK.
Okay, so we're finding people who live in London or generally in the UK, and if you're having trouble
running this, make sure you're using a modern browser like Chrome or Firefox.
Opera I think works as well.
I would just use Chrome though.
That's what I'm using.
And if it doesn't work at all, it's really not a big deal.
We're using this for 5 minutes in this one video and then never again.
So we can also do something simpler, like look at some of these other tables on the right here.
These are all different tables that we have.
Let's look at products.
So the command would be select star from.
And you don't even have to capitalize it the same as me, but I'm going to do it.
It's easier to kind of read and differentiate.
And down here you'll see we have 77 products that we get.
I can do things like reorder, so I can get all my products and then order them by the price in descending
order.
Order by price.
You can see price is one of these values, what we call a column order by price in descending order,
DSC And the highest priced item is, I think this is some sort of Bordeaux or bottle of.
Yeah, I think it's Bordeaux.
And then, I don't know, we got sausages.
50 bags of 30 sausages is $123 or hundred and 23.
Whatever the currency is here, we can change that order.
And you'll see the cheapest items are here are two and a half, four and one half, six, seven, all
the way up to 263.
But we can even get more complicated.
We can do things like this query here, which if you want to run this, don't type it, don't worry
about it.
You can either watch me do it or just copy it from this video or from the slides.
I'll click the copy button and I'm going to run this.
And this is obviously more complicated.
It has more lines involved.
So you can I make this larger here does not appear that way.
So we'll dissect it here.
We're looking to get the customer name and then we're counting something, counting star, whatever
that means from the customer's table.
But we're doing this thing called a join inner join orders.
We're basically combining information from the customers table and we're combining that with information
from the orders table.
And that way we're able to figure out how many orders each customer made and who made the most.
So this guy, Ernst Handle Handle has made ten orders.
And then down here we have a lot of people who've only made one order.
So we're also sorting once again by the number of orders that they've made.
So we're going to go towards something like this later on in the course where we have a bunch of different
tables.
So we got photos and likes.
We're working with hashtags and some of our selections.
We're working with users.
This is sort of an Instagram clone database that we'll be working with later on.
But we've got a lot of stuff going on.
We have select, we have count, we have inner join inner join group by order, buy limit.
These are all things that we are going to learn throughout the course.
So my point in this video is not to overwhelm you with all this syntax, but just to show you this basic
process of interacting with the database, even if it is in a browser filled with ads on the sides.
Hot topic ads.
Wow, I haven't seen those in a while.
It doesn't really matter.
The process is the same.
We'll be typing our code in an editor like this.
We're all typed some query and then I'll execute the query.
Or maybe from my terminal I'll execute the query, but we're going to get results back.
Either way, they just look slightly different in the browser.
Okay, So as I said, we're going to do some more complicated things later on.
Even things like this here we've got a bunch of stuff happening.
If null round case when count count left, join here.
There was an inner join.
We're going to learn all about joints, all of this stuff grouped by.
There's a lot that we have to cover.
But the core mechanic, as I've mentioned many times in this video, is we write some sort of query.
We want to find something out from a database and then we run that query and we hopefully get a result.
Of course, we could get an error, right?
If I do something that doesn't exist, like let's simplify this, let's select Star, let's look at
the shippers table, shippers, some sort of shippers information.
Well, if I mess up the spelling shippers instead, I'll get an error.
This time the error is in the browser.
It's just a little pop up here.
It says you could not run that statement.
I don't know what you're talking about.
So like any programming language or technical language, we have to be precise.
We have to use the correct spelling and formatting.
But that's what this course is here to teach you.
So finally, instead of doing select, which is what we've been doing over and over and over, and we're
going to learn what select really means.
But basically it's retrieving information.
Instead of doing that, we can do something different.
We can delete, we can drop a whole table.
Now, when I run this command drop table customers, just to remind you, if I do select star from customers
and you can do this along with me, I'm getting 91 different customer records.
And if I instead say drop table customers, they're all going to go away.
Okay.
It tells me you've made changes to the database.
How do we know that it worked?
Well, if I try and select star from customers again.
Oh, no.
I get an error.
It says no such table customers.
It's gone.
So just to show there are other commands, it's not all about retrieving information.
We can update, we can add or insert information.
We can drop delete tables or individual entries.
And then if you do want to keep exploring this little data set here in the browser, you can click restore
database.
And now we should have customers again.
And we do so they're not gone forever.
But in the real world, if you do drop a table, it often is gone forever.
And that's the thing we'll discuss when we get to that section.
So that is our quick taste of my SQL.
We can run queries, get results, those queries can do different things.
We can ask to find information, find the highest selling item in our database, or delete the lowest
selling items, or add a new item or update an item to price.
We can interact with the database via these queries that we write and then execute.
So the next thing we have to do, unfortunately is talk about installation, talk about high level questions
around SQL in general versus my SQL, talk about different types of databases, but we'll keep it brief
so that we can get on to the code as soon as possible.