how to use distinct in where clause | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

how to use distinct in where clause

when we created a table with some duplicates how to print all the data just like select * from tablename where distinct column_name;

9th Jan 2020, 10:23 AM
Lakshmi Reddy Sanikommu
Lakshmi Reddy Sanikommu - avatar
4 Respostas
+ 2
AFAIK DISTINCT is used to filter the results so that only one of the duplicates is included in the resultset. Also I don't see a lot use of DISTINCT when all the columns are selected from the table (your query - SELECT * ...). * DISTINCT is not used along the WHERE clause. https://www.w3schools.com/Sql/sql_distinct.asp
9th Jan 2020, 10:37 AM
Ipang
0
How can we print all the column s from the table based on DISTINCT column_name Yeah ! There may be no lot of use bro but it requires in atleast some situations know
9th Jan 2020, 12:03 PM
Lakshmi Reddy Sanikommu
Lakshmi Reddy Sanikommu - avatar
0
DISTINCT is used in the Select statement Select Distinct columname from tablename this will get you a list of all of the values that appear in that column without duplication If a column has a certain set of values that are allowed, but you canā€™t remeber what they are, like the state and territory code of USA, you can use this to get close if running against a well populated DB. It is also often used to hide a bad join ;)
9th Jan 2020, 10:18 PM
SQrL
SQrL - avatar
0
You can use distinct with where select distinct column_name from Table_Name where Condition ; select distinct fname from Table_name where e_id > 7 ; here DISTINCT clause is used to remove duplicates value from column distinct is use with aggregates: COUNT, AVG, MAX, etc. when you apply specific condition in where at that time you can not use distinct becuse it's display only one record
6th Feb 2020, 5:26 AM
Ishan Shah
Ishan Shah - avatar