Home Backend Development PHP Tutorial 如何获取省份和城市

如何获取省份和城市

Jun 13, 2016 pm 12:10 PM
nbsp pro select

怎么获取省份和城市?
id pid paths  pro  city
1   0   0     中国 
2   1   1,2   湖南
3   1   1,3   湖北
4   2   1,2,1 湖南  长沙
5   2   1,2,2 湖南  娄底
6   3   1,3,1 湖北  武汉

最后结果:

湖南   长沙  娄底
湖北   武汉

忙了一天晕了,好难弄


------解决思路----------------------

select pro, group_concat(city order by paths) as city<br />  from表<br />  where city!=''<br />  group by pro<br />
Copy after login
<br />pro city <br />湖北 武汉 <br />湖南 长沙,娄底 <br />
Copy after login

------解决思路----------------------
1、你展示的数据和结果没有体现出无限分类
2、你没有说明查询的依据是什么
3、在 邻接列表算法中,并不需要冗余的 paths 列
    递归和不递归的算法,精华区都有
4、你的 paths 列含义不清,尤其是表示 ctiy 层次的值
5、按我国的行政区划标准,只有 省、市、县、乡 4个层次
加上 国家和村,也就是6个层次,不能说是无限分类,并且变化的概率很小
所以应按 预排序遍历树算法 组织数据

------解决思路----------------------
你是不是想这样体现无限循环的。

id pid paths  pro  city
1   0   0,     中国 
2   1   1,2,   湖南
3   1   1,3,   湖北
4   2   1,2,4, 湖南  长沙
5   2   1,2,5, 湖南  娄底
6   3   1,3,6, 湖北  武汉

取湖南省下的所有市

SELECT `city` FROM  `pro` WHERE instr(`paths`,'1,2,')

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

How to turn off private browsing authentication for iPhone in Safari? How to turn off private browsing authentication for iPhone in Safari? Nov 29, 2023 pm 11:21 PM

In iOS 17, Apple introduced several new privacy and security features to its mobile operating system, one of which is the ability to require two-step authentication for private browsing tabs in Safari. Here's how it works and how to turn it off. On an iPhone or iPad running iOS 17 or iPadOS 17, Apple's browser now requires Face ID/Touch ID authentication or a passcode if you have any Private Browsing tab open in Safari and then exit the session or app to access them again. In other words, if someone gets their hands on your iPhone or iPad while it's unlocked, they still won't be able to view your privacy without knowing your passcode

Win10/11 digital activation script MAS version 2.2 re-supports digital activation Win10/11 digital activation script MAS version 2.2 re-supports digital activation Oct 16, 2023 am 08:13 AM

The famous activation script MAS2.2 version supports digital activation again. The method originated from @asdcorp and the team. The MAS author calls it HWID2. Download gatherosstate.exe (not original, modified) from https://github.com/massgravel/Microsoft-Activation-Scripts, run it with parameters, and generate GenuineTicket.xml. First take a look at the original method: gatherosstate.exePfn=xxxxxxx;DownlevelGenuineState=1 and then compare with the latest method: gatheros

Which one is worth buying, Xiaomi Mi Pad 6 or Pro? Which one is worth buying, Xiaomi Mi Pad 6 or Pro? Feb 07, 2024 pm 08:36 PM

Many users are not sure which one is worth buying, Xiaomi Mi Pad 6 or Mi Pad 6. From the configuration point of view, the higher configuration of Pro is definitely recommended, but it also depends on the price and their own budget, and the different product positioning groups are also different. Which one is worth buying, Xiaomi Mi Pad 6 or Pro? Answer: Xiaomi Mi Pad 6 Pro will be better, both in terms of performance and camera battery life. 1. Processor Xiaomi Pad 6: Snapdragon 870 Xiaomi Mi Pad 6 Pro: more powerful first-generation Snapdragon 8+ processor 2. Battery size Xiaomi Mi Pad 6: 8840mAh, 67W second charge Xiaomi Mi Pad 6 Pro: 8600mAh, 33W The fast-charging Xiaomi Mi Pad 6 will have better battery life, but charging will be slower. 3. Take photos with Xiaomi Mi Pad 6

iPhone 15 Pro Max vs iPhone 14 Pro Max: What are the comparisons and differences between them? iPhone 15 Pro Max vs iPhone 14 Pro Max: What are the comparisons and differences between them? Sep 19, 2023 pm 08:29 PM

iPhone 15 Pro vs. iPhone 14 Pro: Specs Comparison Here is a spec comparison between iPhone 15 Pro Max and iPhone 14 Pro Max: iPhone 15 Pro Max iPhone 14 Pro Max Display size 6.7 inches 6.7 inches Display technology Super Retina 2,000 nits Dimensions 6.29x3.02x0.32 inches 6.33x3.06x0.31 inches Weight 221 grams 240 grams

How to start Xiaomi Mi Band 8pro How to start Xiaomi Mi Band 8pro Jan 14, 2024 am 08:51 AM

Many users don’t know how to turn on the Xiaomi Mi Band 8 when they first come into contact with it. In fact, the method is very simple. We only need to find the USB data cable and connect the watch to the power supply, and then charge it for a while. You can press the button to turn on. How to turn on Xiaomi Mi Band 8pro 1. First install the watch, that is, connect the theme and the strap on both sides. 2. Then when we turn on the watch for the first time, we need to connect the charging cable. The connection method is at the bottom of the watch. 3. Wait for the watch to vibrate to power on, and then connect to your phone. >>>

See all articles