- 6/8/2025
Learn the basics of the SQL SELECT statement in this quick tutorial! We'll cover retrieving data from tables using simple examples. No database installation required! Practice along using the mycompiler.io link below. Plus, see the SELECT statement in action using a real MySQL database. Perfect for beginners!
---
Code from the video: https://www.mycompiler.io/view/Jd9aaO6JUOx
Run SQL code online free: https://www.mycompiler.io/new/sql
---
Get my coloring book, Watson the Time-Travelling Dog 🐕🦖👇
https://watsoncoloringbooks.com/book1-locations/
---
Our website: https://watsontechworld.com
---
00:00 Intro and overview of tutorial
01:00 Teaching about SELECT statement in a document
02:20 Showing mycompiler.io with SQL next to spreadsheet
04:04 Creating the table and inserting data
04:50 Notes about SQL semicolons P1
05:15 Info about comments in SQL
05:57 Running first SELECT statement with *
06:35 More example SELECT commands P1
10:38 Notes about SQL semicolons P2
10:57 More example SELECT commands P2
12:07 SELECT commands in a MySQL database
14:22 Conclusion about SQL SELECT statement
---
#SQL #SQLTutorial #MySQL #SQLSelect #LearnSQL #SQLForBeginners #SQLBasics #DatabaseTutorial #BeginnerSQL #database
---
Code from the video: https://www.mycompiler.io/view/Jd9aaO6JUOx
Run SQL code online free: https://www.mycompiler.io/new/sql
---
Get my coloring book, Watson the Time-Travelling Dog 🐕🦖👇
https://watsoncoloringbooks.com/book1-locations/
---
Our website: https://watsontechworld.com
---
00:00 Intro and overview of tutorial
01:00 Teaching about SELECT statement in a document
02:20 Showing mycompiler.io with SQL next to spreadsheet
04:04 Creating the table and inserting data
04:50 Notes about SQL semicolons P1
05:15 Info about comments in SQL
05:57 Running first SELECT statement with *
06:35 More example SELECT commands P1
10:38 Notes about SQL semicolons P2
10:57 More example SELECT commands P2
12:07 SELECT commands in a MySQL database
14:22 Conclusion about SQL SELECT statement
---
#SQL #SQLTutorial #MySQL #SQLSelect #LearnSQL #SQLForBeginners #SQLBasics #DatabaseTutorial #BeginnerSQL #database
Category
🤖
TechTranscript
00:01Hi everyone, in this video I'm going to teach you about the SQL SELECT
00:05statement and I'm going to try to make this a simple tutorial but also very
00:11useful and it can be interactive for you. So I'll give you a link to where
00:16you can practice it by yourself and I'll try to make this a useful tutorial.
00:23Eventually I'm going to show you how to have some text and we can try out
00:29using the SELECT statement with a few few different lines and that doesn't
00:35require any installation of database and eventually I'll show you how to
00:40actually run it in a real database. I've made a temporary database or teaching
00:45database and we're going to be using this data for the tutorial and it's a pretty
00:54simple table. It's about salaries and I'll go over it in a bit. Okay, so let's get
01:01started. The SQL SELECT statement. What is it and how does it work? Okay, so SELECT is a
01:11way to retrieve or get data from a table in a database and a table in a database is
01:17kind of like a table in a spreadsheet. So it's kind of like this. Essentially we'll
01:22be getting data from a spreadsheet like this and yeah so it's like getting from a
01:31spreadsheet in Excel or Google Sheets etc. The basic form of a SELECT statement is
01:37something like SELECT some columns from some table where some filters. Here are a
01:46few examples. So SELECT star this means select all columns and salary is the
01:52salary table and for example let's say we want to get the name, career, and yearly
01:59salary from the salary table. That would be equivalent to name, career, and yearly
02:06salary. That would be the equivalent of getting all of this data and then we
02:10would ignore this data. That's what the SELECT statement would do. Okay, so I'm
02:14going to show you side-by-side with the data and doing some commands.
02:22Okay, so I tried to zoom in as much as I could to make this text as big as I could.
02:29On the left side here I have the spreadsheet and I'm actually blocking one
02:33of the columns to save space. We'll just deal with these columns and on the right
02:38side here I'm using a website called mycompiler.io and basically what this is a
02:47great site where you can basically run code online, different programming code and we're
02:54going to try with SQL. So you don't actually need to install any software. All you need
03:02to do is just go to this URL and this is going to be the default code but I'll give you a link to where
03:13you can copy all of my code and you can override the code and run it and although if you want you
03:22can follow along with the tutorial just copy all my code and you can follow it along. Okay, so the first
03:28things first is that before I show you about the SELECT statement first we have to actually create the
03:38table and we have to insert values so that means we have to fill up the table. I'm not going to teach
03:46you about this but you can just copy it and paste it and basically you can take it as as is
03:58and a second here
04:04okay so the first thing is all you need to do is you can just take this as given so you can copy and
04:10paste all this text this just fills up the table and nothing happens at first
04:16and you can actually run this code before we do anything you can run the code and you can run it
04:24with this just click on run and give me a moment here okay I have an actual I actually have a SELECT
04:34statement I'm going to rerun it okay so you should assuming that all of these are commented out you
04:40should see something that says execution completed and that just means basically nothing you don't see
04:46any actual output but there's no errors which is good and one important thing about SQL is that all
04:53the statements have to end with a semicolon so if you accidentally delete a semicolon or leave one out
05:00you might get an error and it might complain and refuse to work okay so again I'm going to assume that you
05:06already have this and I'm going to show you these these lines now so real quick so any line that has
05:16a dash dash like this those are comments and I this is also a comment which means the system will ignore
05:24it but you can delete all these lines if you want with the dash dash space those are just my commentaries
05:30but the ones that have the hash like this those are actual commands you can run if you remove the hash
05:38and I'll show you what I'm talking about so I just removed the hash for this and it actually ran this
05:43command but if I put the hash there again and rerun it you should get no output and then if I remove the
05:51hash for these other ones it's going to run the command okay so what this says select star
06:00from salary what this does is it selects all the columns and all the rows from the table called salary
06:12and the output is all of it and notice I'm not showing you the age group but it includes the age
06:18group so it shows the name career yearly salary gender age age group and all the different rows
06:24values so star means all columns but now let's say we don't want all the columns let's say we want
06:36and I'm going to comment this one out just to prevent having so much output let's say for example we want
06:43the name column okay so I just moved the spreadsheet again so it's easier to see now let's say we want
06:55just the name column and the career column and the yearly salary column from this and this is so select
07:06this column this column and this column we have commas in between and then the from we have to choose
07:13a table so the salary table which we defined earlier this I defined the salary table but you can copy all
07:20that code and what this is going to do is just give us the those three columns so notice here we just have
07:27name career yearly salary and I'll move this over here name career yearly salary we've got Brad
07:34who's a doctor has 150 000 per year sana as an idol and a singer has almost 1.5 million a year and so on
07:43and yeah so that basically got all of this data and it gave us three columns
07:54now let's try one more instead now let's do the same thing but instead just get females
08:02and I defined uh the gender column here with m being male and f is female and what this is saying
08:10here this this is basically the same command as above but now we added a where statement and where is a way
08:18to filter so instead of getting all of the rows where is a way to filter the rows so gender equals female
08:27that's a filter and let's run this so the first female is sana and then we have leia and then cheryl
08:42and julie we see here as sana leia cheryl julie and so on and that got just the females and notice that
08:50there's much fewer rows because the males were removed but now let's say we want to get all the males
08:56males instead of the females let's say let's get the males so the gender is uh is m and i'm going to
09:05comment this one out so if we want just the males we've got brad luke tony right here brad luke tony mike
09:14nick and so on and that's a way to filter by the males and now let's uh filter by the yearly salary
09:24so for example so for example let's say that we want people who have a salary of 150 000 or more per
09:34year for example leia is a chemical engineer nick we've got um sana brad but people who make less
09:42less than 100 000 per year tony mike pilar sarah so they're going to get filtered out and what this
09:51statement does this means greater than or equal to and if we had if we didn't have the equal that would
09:58mean strictly greater than 100 000 but this means greater than or 100 greater than or equal to 100 000
10:05and let's run this now so now we're just filtering by the yearly salary we're not filtering by gender
10:15and then we can see here we have brad who has 150 000 sana leia nick sonia and mary all of them have
10:26more than 150 000 and notice that there are none that have less than 100 000 so that's a good way to filter
10:33out and let's do another one here now i mentioned about semicolons technically sql statements can run
10:45over several lines one reason that they have semicolons is so the system knows that it's the end of the
10:51statement so we can actually run it uh for example here here what we're doing is we want basically the
11:00name column the career column and the yearly salary column from salary where the yearly salary is
11:06greater than 100 excuse me greater than or equal to 80 000 so for example uh luke will now be part of
11:16that previously he's less than 100 000 so he wasn't part of that but he will be part of this
11:22and also we can fill okay so what this is saying is we want all the males greater than or equal to 80 000
11:29so we have greater than or equal to 80 000 and then i added the and and means another filter so two filters
11:37and uh i'll show you the output here
11:42so get the name career yearly salary
11:45from this table salary where the yearly salary is greater than or equal to 80 000 and they're male
11:50okay so look we've got brad luke and nick all of these people have they're all male and they're all
11:59have a salary of 80 000 or more
12:06okay now what i want to show you is a real database instead of just this i'm going to show you a database
12:11um in mysql with the same data and showing you how to run it there
12:20okay so this is the same data
12:23and notice we have a salary a salary table and the salary table this is a mysql command that says
12:38tell me about the columns of this table and what i'm going to do is say select star
12:44from salary and what this does is this gives us the same data this is the name column career yearly
12:53salary gender age age group and that gives the same data and notice yeah sql is is really incredibly is
13:01amazing and uh you can see the benefits of sql over using a spreadsheet if you use it enough but
13:08uh it really is very very useful okay now let's say we want the name career and yearly salary
13:20from salary so this is the salary column excuse me the salary table so this is the name column
13:26career column yearly salary column and the salary table so notice here we have the name career yearly
13:34salary salary and so on and if we want to filter by for example and and real quick it is good practice
13:43to have these the sql keywords as all caps technically you don't need to have it all caps but it is good
13:54practice where gender equals female okay so this is um getting just the females and let's say for
14:04example we want the females and yearly salary greater than or equal to 100 000 so these are the females
14:17who make pretty good money at least 100 000. okay so the select statement is incredibly useful and i just
14:26showed you now in in a database an actual database in mysql and on this website in the website
14:31and i'm going to give you a link so you can copy all of this code and again as a reminder you can go
14:39to this website my compiler.io you can search for sql and you can run the code that i gave you and do it
14:48interactively okay i hope you enjoyed this video if you enjoyed it i'd appreciate it if you could subscribe
14:52to a follower of this channel and see you in the next one thank you
Recommended
14:57
|
Up next
1:11:49
1:08:19
1:35
1:58:00
56:07
28:54
2:11
49:32
2:54
14:35
1:55
14:58
15:00
2:59
14:58