LMSouq
database Open

What's faster, SELECT DISTINCT or GROUP BY in MySQL?

VA
vava
1 month ago
3 views
Problem Description
If I have a table CREATE TABLE users ( id int(10) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL, profession varchar(255) NOT NULL, employer varchar(255) NOT NULL, PRIMARY KEY (id) ) and I want to get all unique values of `profession` field, what would be faster (or recommended): SELECT DISTINCT u.profession FROM users u or SELECT u.profession FROM users u GROUP BY u.profession ?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base