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:
sequence |
Field name |
Field Description |
Data Type | is
empty |
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 ~