Three-level linkage effect (example: Province-city-district)

Source: Internet
Author: User
display of three-level linkage effectdatabase table Design Query statement writing event add

The first is to create a table for two levels, three levels, or even higher-level linkage effects.
The next step is to build a table with the simplest and most brutal (at the expense of database memory): The Data dictionary:

is
sequence Field name Field Description Data Typeempty Notes
1 Firstlevel First level varchar N such as: Province
2 Secondlevel Second level varchar N such as: City
3 Thirdlevel Third level varchar N such as: District
Simple data:
Firstlevel Secondlevel Thirdlevel
Guangdong Guangzhou Tianhe
Guangdong Guangzhou Panyu
Guangdong Shantou Jinping
Shaanxi Xi'an Weiyang
A B C

The second is to write our query statements, used to filter out each level after the linkage of the next level of results: three-level linkage only need to write two SQL statements:
Sieve province: SELECT DISTINCT firstlevel from
Province Sieve City: SELECT Secondlevel from the area WHERE firstlevel= ' a ';
City Sieve: SELECT thirdlevel from area WHERE secondlevel= ' B '
Through the first SQL statement can be filtered through a B: for example, we chose Guangdong (a), then the result of screening is B: Guangzhou or Shantou
Then by selecting one of them, for example Guangzhou (b), then you can filter out the results C: Tianhe or Panyu
Finally choose one of the line ~

Finally, the front-end development of the event, the incident: for example, C # checkbox in the onclick () event, the SQL statement written in the event.
The first checkbox in load () must write "Sieve province" to filter out all the results to fill in the first checkbox
In the onclick () event of the first checkbox, the result of filtering out the city by "provincial Sieve City" is populated into the second checkbox.
In the onclick () event of the second checkbox, populate the Third checkbox with the result of filtering out the area from the city sieve area.

Ok province urban three-level linkage completed ~ There are other good ideas, or what the wrong place, hope can point out oh ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.