Learn to utilize the incredibly powerful and useful database tool, Microsoft's SQL Server as well as SQL Server Management Studio through this series of tutorials! This episode covers a detailed understanding of the Select operation for grabbing column data out of a specific table in SQL!
Learn the basics of a standard Select, From, Where statement query in just minutes! SQL is an incredible tool for any employee to be familiar with for their job or as an independent software developer!
If you want to see anything specific on the channel or have technical questions about anything leave a comment on our of our videos and we will get back as soon as we can!
Thanks for watching and supporting the channel!
hello welcome back to the channel
today's episode is going to be uh part
two of our intro to sql tutorial series
and today specifically we'll be looking
at how to use the select statement
inside of microsoft sql server and the
microsoft sql server management studio
so if you
haven't downloaded or gotten started
with sql yet i recommend you check out
the previous video otherwise if you're
just here to get some knowledge on the
select statement then let's get right
into it
so the standard method for
pulling data out of tables in sql is
using their select statement and
comboing that with a from statement
that's going to tell you what table to
grab it from
so let's go ahead and look at this
employee table
that i've already made
we have six employees in here
a position that they work and then the
salary that they currently get paid
this is fairly standard
data that you might keep in a table and
typically in sql these tables get a lot
more rows and a lot more columns and a
lot more complicated but we've got a
nice basic one here for learning how to
use the select statement
so let's just start by saying we want to
grab everything out of a table we just
want to see everything that's in a table
uh sql has their special character for
that is the star or the asterisk for
selecting everything so if we go ahead
and say select everything from the
employee table and then execute this
we see in our results here okay we've
got all three columns we've got
the employee name their position worked
and their salary at the company
just by using the star so that's useful
but let's say we just want one of these
columns we just want to know the
employee name because currently we're
just trying to make a
list of the employee name
well you can type in the specific column
name you see at the top of the columns
you can type in the specific column name
that you want to see and then run it
again and you'll have just the employee
name the important thing to know is if
later in your query you want to
manipulate data now
you have only grabbed the employee name
so you can't use the salary unless you
also reference the salary
but so this works for multiple columns
if we want to know the employee and
their position
but we don't want to know
the salary it's private and we're just
trying to show a list of our employees
you separate your columns by a comma and
then you run this again and you get
employee and position there
so that's pretty cool
um it it it's not just two it works uh
unlimited number of times you can go up
to
um you know however many columns you
have but one thing that you should note
is if you have a misspelling here
it's going to tell you invalid comment
com a column name and just not give you
data back
so if you use
an external tool to create sql queries
like you're writing from an in hmi for a
customer system or a web interface and
that's where you create a sql query it
will just fail and return no data if you
use an invalid column name
which is why i like writing a lot of my
queries for the first time in the
management studio run it a few times see
that it executes successfully and gives
you the data back that you would be
hoping for
and then export it to whatever tool you
actually use to pull the data
um
so uh really the the cool thing about
the select is you can narrow down the
data that you actually want to see
but also what's important to think about
is if you're just grabbing data
certain data
like just the salaries you have to think
is this useful information when i
structure a query because if you just
pull salary and you don't know position
or name or anything like that
who's going to do what with this data so
sometimes a person might say like oh i
just need to see the average salary for
an employee company that's fine you
could limit it to this
but most of the time
if you're the one writing the sql
queries you also have to do some
thinking about what data would actually
be useful for the person who's going to
be reading this data
so
just that's a good way to think about
how you structure your
queries but really this is a nice short
video we're just taking a look at the
select statement the star will grab
everything beyond that
you want to reference specific columns
and that's how you use the select
statement within one table so that's it
for today hope you found this useful
feel free to leave any questions or
comments you have on this in the
comments below
and if you found this or anything else
on the channel useful i really
appreciate a like and a subscribe it
helps the channel a lot and as always
thanks for watching and good luck with
your code thanks bye