1.mysql按多字段分組
select * from student group by sex,age;
查詢結果先按sex
分組,然後按age
分組。
2.遍歷Map中的值
假設有一變量Map<String,Object> map
,知道它有兩個key值:name
和age
,那麼要取key對應的值,只需要 map.get(key) 就可以了。
若不知道具體的key值,則可以使用keySet來遍歷key和value:
for (String key : map.keySet()) {
String myKey = key;
String value = (String)map.get(key);
}
注:除此之外還有另外幾種不同的方式可以遍歷Map,可以參考遍歷Map的四種方法。