Difference between SELECT * FROM TABLE vs SELECT DISTINCT * FROM TABLE
Loading
Difference between SELECT * FROM TABLE vs SELECT DISTINCT * FROM TABLE
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Brahma Prakash ShuklaPosted Oct 18, 2022, 8:10 AM
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".Aravind GovindarajPosted Oct 13, 2022, 10:45 PM
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....
Jignesh KumarPosted Oct 13, 2022, 3:26 AM
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.
Abhishek YadavPosted Oct 13, 2022, 1:49 AM
select * from table shows all the rows
but select dustinct * shows only unique values dublicate records are not shown
Amit KumarPosted Sep 20, 2022, 4:45 AM
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.
Vishal JoshiPosted Sep 19, 2022, 5:05 AM
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.
You can use DISTINCT on single column also as below:
Vishal YelvePosted Sep 19, 2022, 4:59 AM
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 MohantyPosted Sep 19, 2022, 4:46 AM
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.
Uday DodiyaPosted Sep 19, 2022, 4:46 AM
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