SQL Distinct Keyword

0
46

sqltuts

The distinct keyword is mainly  used with the Select statement  in order to get  unique values from the desired table. Distinct removes all the redundant records while retrieving from the database.

 

Syntax for DISTINCT Keyword

  1. SELECT distinct column-name from table-name;

 

Example

Consider the following consumer table.

  1. select distinct salary from consumer;
Consumer id name age salary
10 rajat 20 90000
11 karan 45 85000
12 ram 37 67000
21 Shyam 41 85000
23 jon 33 90000

 

The above query will return only the unique salary from consumer table

salary
85000
Facebook Comments
(Visited 62 times, 1 visits today)
SHARE
Previous articleSQL Temporary Tables
Next articleSQL GROUP BY Statement
Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!

LEAVE A REPLY

Please enter your comment!
Please enter your name here