Parts level
A
B
C
D
The users table
User area
The northeast
Northwest
North China
Central China
East China
The southeast
Southwest
When parts grade A can match the northeast, northwest
When the grade B parts can match the northeast, northwest, north China, central China, southwest
When the parts level C can match southeast
When grade D parts can match central China, southwest
How to achieve this?
CodePudding user response:
I need a relational table
The CREATE TABLE # A (component level VARCHAR (20))
# INSERT INTO A values (' A ')
# INSERT INTO A values (' B ')
# INSERT INTO A values (' C ')
# INSERT INTO A values (' D ')
The CREATE TABLE # B (user area VARCHAR (20))
INSERT INTO # B values (' northeast)
INSERT INTO # B values (' northwest)
INSERT INTO # B values (' north ')
INSERT INTO # B values (' central China ')
INSERT INTO # B values (' east ')
INSERT INTO # B values (' southeast)
INSERT INTO # B values (' southwest)
The Create table # C (component level VARCHAR (20), the user area VARCHAR (50))
INSERT INTO # C values (' A ', 'northeast, northwest)
INSERT INTO # C values (' B ', 'the northeast, northwest, north China, central China, southwest')
INSERT INTO # C values (' C ', 'the southeast)
INSERT INTO # C values (' D ', 'central China, southwest)
Select * from # A, A, B # B
The where (select COUNT (1) the from C # C where c. parts level=a. parts level and c. user area like '%' + b. user area + '%') & gt; 0
CodePudding user response:
I only have permission to query the database, what function can realize the function?CodePudding user response:
Build a relational table should be built like upstairs to answer directly, rather like he code to build a relational tableCodePudding user response: