为此,请使用 GROUP BY 和 ORDER BY:select yourColumnName, count(*) as anyAliasName from yourTableName group by yourColumnName order by yourColumnName;让我们创建一个表:mysql> create table demo7 -> ( -> id int NOT NULL AUTO_INCREMENT, -> first_name varchar(50) -> , -> primary key(id) -> ); 插入一些记录到表中:mysql> insert into demo7(first_name) values('John'); mysql> insert into demo7(first_name) values('David'); mysql> insert into demo7(first_name) values('John'); mysql> ... 阅读更多
以下是实现多个 LIKE 运算符和 ORDER BY 的语法:select *from yourTableName order by ( yourColumnName like '%yourValue1%' ) + ( yourColumnName like '%yourValue2%' ) + . . N desc;让我们创建一个表:mysql> create table demo2 -> ( -> id int not null auto_increment, -> name varchar(100), -> primary key(id) -> ); 插入一些记录到表中:mysql> insert into demo2(name) values('John'); mysql> insert into demo2(name) values('David'); mysql> insert into demo2(name) values('... 阅读更多