SQL queries are sorted by specified fields
city_name is the field name, now press ("Beijing","Shanghai","Guangzhou") To sort out the data in sequence? Do not know what database you have, if it is Oracle:select count(city_name), city_name from tuan_info where source_type = 1 and city_name in("Beijing","Shanghai","Guangzhou") group by city_nameORDER BY INSTR ('Beijing, Shanghai, Guangzhou', city_name); ORDER BY CHARINDEX(city_name, 'Beijing, Shanghai, Guangzhou') if SQL Server
questioning
SQL Server, how to write oh, give a complete point statement, okay?
answer
select count(city_name), city_name from tuan_info where source_type = 1 and city_name in("Beijing","Shanghai","Guangzhou") group by city_nameORDER BY CHARINDEX(city_name, 'Beijing, Shanghai, Guangzhou') The SQL in front is the same ah. Just add an ORDER BY sort process.
questioning
[SQL] select count(city_name), city_name from tuan_info where source_type = 1 and city_name in("Beijing","Shanghai","Guangzhou") group by city_name ORDER BY CHARINDEX(city_name, 'Beijing, Shanghai, Guangzhou');[Err] 1305 - FUNCTION data_group.CHARINDEX does not exist
answer
What kind of database is this? CHARINDEX is a SQL Server function.
questioning
That, that's MYSQL, what should I do?
answer
MySQL changes a function. INSTRselect count(city_name), city_name from tuan_info where source_type = 1 and city_name in("Beijing","Shanghai","Guangzhou") group by city_nameORDER BY INSTR ('Beijing, Shanghai, Guangzhou', city_name)