Home > Database > Mysql Tutorial > 列出美国每个州及一个邮编

列出美国每个州及一个邮编

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:54:33
Original
1400 people have browsed it

有一个zip表,上面有美国所有的州和邮编,怎么列出一个邮编给每个州? 每行有两个列,分别是州名和邮编 当时想了好长时间都没有想出来, 后来看别人的开窍了, select state, max(zipcode) from zip group by state group by 很奇妙,但是很难用,主要是思维

有一个zip表,上面有美国所有的州和邮编,怎么列出一个邮编给每个州?

每行有两个列,分别是州名和邮编

当时想了好长时间都没有想出来,

后来看别人的开窍了,

select state, max(zipcode) from zip group by state
Copy after login

group by 很奇妙,但是很难用,主要是思维太怪了。

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
ubuntu mongodb 出现 exception: connect failed
From 1970-01-01 08:00:00
0
0
0
git出错: Cannot save the current index state
From 1970-01-01 08:00:00
0
0
0
An error occurred
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template