1

Why shouldn't I use GROUP BY in place of DISTINCT when writing a query that does not contain an aggregate function?

What is the best practice?

Seymour
  • 7,043
  • 12
  • 44
  • 51
user2948897
  • 169
  • 3
  • 9
  • I thought Group By was necessary when you list out other column names along with a distinct column name. – Mukus Nov 18 '13 at 19:42

1 Answers1

3

If you only need to remove duplicates, use DISTINCT, since its usually faster. GROUP BY should be used when you are going to write aggregate operations/functions.

Also, not to be rude or anything but a simple search would have also gotten you the following results

Whats faster select distinct or group by in mysql

Is there any difference between group by and distinct

Community
  • 1
  • 1
Armen Abrami
  • 224
  • 2
  • 8