SQL Select Distinct Statement
The Select Distinct statement is used to select or fetch only the (different) Distinct data from a database table. There are many duplicate values present in the database table, so Distinct is used to list different values.
SELECT DISTINCT Syntax :
The syntax of the SELECT DISTINCT statement is −
SELECT DISTINCT column1, column2, ... columnN, FROM table_name;
SELECT DISTINCT Example :
Consider the Customer table with the following records -
CustomerID | CustomerName | Age | Address | CustomerSalary |
---|---|---|---|---|
1 | Aarav | 28 | Udaipur | 28000 |
2 | Vivaan | 25 | Mumbai | 30000 |
3 | Reyansh | 28 | Chennai | 35000 |
4 | Muhammad | 24 | Udaipur | 50000 |
5 | Sai | 30 | Mumbai | 27000 |
Test Case:-The following code is an example, which would fetch the DISTINCT Address fields of the Customer available in CUSTOMERS table.
SELECT DISTINCT Address FROM Customer;
The result for the respective sql query is as follows −
Address |
---|
Mumbai |
Chennai |
Udaipur |
Exercise:-
1. ____ _____Country FROM Customers;
View Answer
2. SELECT * FROM Customers ______ _____ = _____;
View Answer
Visit :
Discussion
pHqghUme
555
pHqghUme
555
pHqghUme
555
pHqghUme
-1 OR 2+361-361-1=0+0+0+1 --
pHqghUme
-1 OR 3+361-361-1=0+0+0+1 --
pHqghUme
-1 OR 3*2<(0+5+361-361) --
pHqghUme
-1 OR 3*2>(0+5+361-361) --
pHqghUme
-1 OR 2+621-621-1=0+0+0+1
pHqghUme
-1 OR 3+621-621-1=0+0+0+1
pHqghUme
-1 OR 3*2<(0+5+621-621)
pHqghUme
-1 OR 3*2>(0+5+621-621)
pHqghUme
-1' OR 2+499-499-1=0+0+0+1 --
pHqghUme
-1' OR 3+499-499-1=0+0+0+1 --
pHqghUme
-1' OR 3*2<(0+5+499-499) --
pHqghUme
-1' OR 3*2>(0+5+499-499) --
pHqghUme
-1' OR 2+948-948-1=0+0+0+1 or 'Wl3Dyr6z'='
pHqghUme
-1' OR 3+948-948-1=0+0+0+1 or 'Wl3Dyr6z'='
pHqghUme
-1' OR 3*2<(0+5+948-948) or 'Wl3Dyr6z'='
pHqghUme
-1' OR 3*2>(0+5+948-948) or 'Wl3Dyr6z'='
pHqghUme
-1" OR 2+206-206-1=0+0+0+1 --
pHqghUme
-1" OR 3+206-206-1=0+0+0+1 --
pHqghUme
-1" OR 3*2<(0+5+206-206) --
pHqghUme
-1" OR 3*2>(0+5+206-206) --
pHqghUme
if(now()=sysdate(),sleep(15),0)
pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
pHqghUme
-1; waitfor delay '0:0:15' --
pHqghUme
-1); waitfor delay '0:0:15' --
pHqghUme
1 waitfor delay '0:0:15' --
pHqghUme
rAtICdxA'; waitfor delay '0:0:15' --
pHqghUme
-5 OR 101=(SELECT 101 FROM PG_SLEEP(15))--
pHqghUme
-5) OR 499=(SELECT 499 FROM PG_SLEEP(15))--
pHqghUme
-1)) OR 761=(SELECT 761 FROM PG_SLEEP(15))--
pHqghUme
qobkcJYm' OR 795=(SELECT 795 FROM PG_SLEEP(15))--
pHqghUme
A0Eh7Dte') OR 363=(SELECT 363 FROM PG_SLEEP(15))--
pHqghUme
FpHQNHIs')) OR 899=(SELECT 899 FROM PG_SLEEP(15))--
pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
pHqghUme
1'"
pHqghUme
pHqghUme
@@sNK9R
pHqghUme
555
pHqghUme
555
pHqghUme
555