fetch

MySQL Tutorial for Beginners 9 - MySQL SELECT DISTINCT Statement



Sharing buttons:

hello friends welcome to programming

knowledge in our previous video we saw

that how to select specific columns from

a table using a select statement and in

this video we will see that how to

select column specific column by a

select statement but in this scenario we

only wanted distinct values so first of

all let us see how to do it in a

terminal so first open your terminal my

skill I knew until provide password now

let us see which are the databases that

we have so we have data test databases

that we have created so just use that

now show tables student table and just

so you get a force

[Music]

okay so we have this record and let me

insert some water God answered seven to

[Music]

ten times LS

okay no no here you can observe one

thing that whenever we fire this Kaveri

select star from student oh let me just

fire anything very silly name here you

can see region is displaying two x

concepts plane two x + LX is also

displaying two x so because if it

sources the multiple values but we want

we don't want that we want only distinct

values no matter how many times it

present in the database we want my SQL

server to saw it only one time okay so

in this scenario we can use select

distinct and then name of the column

here you can see though there are two

breezin present in the database - L X as

well as - corn but because of this

distinct keyword that we have used here

region is saying only one time LX and so

on so let me just close it and open open

- color match yeah

first we write select name from student

and Phi this query so here you can see

there are duplications in the values as

is out earlier if we want distinct value

and you just need to type distinct

keyword here you can see let me provide

in here then you can see region

brie chain corn is appearing also two

times this is happening because in the

surname field there are no duplications

they are unique values for each name

that we have inserted in our table so

that's why it displaying all the values

again it's also a distinct value so this

is a you can select distinct value from

your table that is one thing that you

need to remember is that you cannot

write this thing keyword anywhere you

want in between this leg statement let

me show you select now ID and then you

specify distinct

[Music]

here you can see it gives an error mmm

you cannot tell the mask when there you

want all the IDS but you want only

distinct name then how it can manage to

show in it in the table format so you

have to specify the distinct giver in

the first place okay thanks for watching

it

you