如果我有桌子
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)
)
并且我想获取profession
字段的所有唯一值,这会更快(或推荐):
SELECT DISTINCT u.profession FROM users u
要么
SELECT u.profession FROM users u GROUP BY u.profession
?