Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Sep 19, 2022, 12:46 AM EDT
DISTINCT means that there will be no duplicate values in the resultset. So SELECT DISTINCT * FROM TABLE means select all columns and skip any rows where the values in all columns match to other row all columns value".
SELECT * FROM TABLE means it will show all rows present in the table.
Vishal JoshiRank #377 · 6.7K reputationPosted Sep 19, 2022, 1:05 AM EDT
DISTINCT Keyword in select statement means no duplicate records in the result. if you just fire SELECT * FROM TABLE NAME it will return all records of the table. and if you add DISTINCT then it will return rows except for duplicates.
Please check the below example to get more clear.
SELECT * FROM EmployeesSELECT DISTINCT * FROM EmployeesYou can use DISTINCT on single column also as below:
SELECT DISTINCT(EMPCODE) FROM EMPLOYEESJignesh KumarRank #91 · 22.9K reputationPosted Oct 12, 2022, 11:26 PM EDT
Hello,
SELECT * FROM TABLE
This query will return all records from given table.
SELECT DISTINCT * FROM TABLE
this query will will eliminate duplicate record. It mean return only unique records from given table.
Aravind GovindarajRank #430 · 5.8K reputationPosted Oct 13, 2022, 6:45 PM EDT
Consider you have 2 records in your table, which does not have any index, primary and unique keys. Both row has same values ....
While using select query you get 2 records however in distinct you get single row. Because it validate all column values if same then it will yield only one row....
Uday DodiyaRank #239 · 10.3K reputationPosted Sep 19, 2022, 12:46 AM EDT
Hello, Jaya
Please refer In the following, I already explain this.
https://stackoverflow.com/questions/73644411/difference-between-select-from-table-vs-select-distinct-from-table/73644633#73644633
Abhishek YadavRank #217 · 11.3K reputationPosted Oct 12, 2022, 9:49 PM EDT
select * from table shows all the rows
but select dustinct * shows only unique values dublicate records are not shown
Vishal YelveRank #178 · 13.6K reputationPosted Sep 19, 2022, 12:59 AM EDT
In SQL Query when we use "*" the query does not eliminate duplicate rows. If the DISTINCT keyword is specified, a query eliminates rows that are duplicates according to the columns in the SELECT clause
Amit KumarRank #459 · 5.4K reputationPosted Sep 20, 2022, 12:45 AM EDT
Hi,
Firstly : SELECT DISTINCT * FROM TABLE in this query DISTINCT always used with. then
SELECT * FROM TABLE : Returns all records from the specific table but
SELECT DISTINCT (column name) * FROM TABLE : It removes the duplicate values in the specific column from the table and then return the result set.
Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted Oct 18, 2022, 4:10 AM EDT
Select * from table will return all the data of the table i.e all the rows which table have.
Select distinct * from table will return the unique values only.It will not return duplicated record.
DISTINCTmeans that there will be no duplicate rows in the resultset, duplicate meaning all columns have the same value in both rows. So yes,DISTINCT *means "select all columns and skip any rows where the values in all columns match some already included row".