Home > database >  The SQL statement, a great god
The SQL statement, a great god

Time:11-08


Table 1 below:

City
Liaoning
Jiangsu
Shanghai
Shanxi

Table 2 is as follows:

Keyword
Shanghai it training
Dark horse hui Shanghai education college
It is the best school school what school
Jiangsu it education
Hepburn makeup nail art training school

to get the following results (according to table 1 word batch query the data in table 2)
Keyword
Shanghai it training
Dark horse hui Shanghai education college
Jiangsu it education

CodePudding user response:

 DECLARE @ city TABLE (city NVARCHAR (10) NOT NULL) 
INSERT @ city (city),
Liaoning 'VALUES (N), (N' jiangsu '), (' Shanghai '), (' shanxi ')

DECLARE @ keyword TABLE (keyword NVARCHAR (100) NOT NULL)
INSERT the @ keyword (keyword)
VALUES (' Shanghai it training), (' dark horse hui Shanghai institute of education), (' what is the best school is it school),
(' it education in jiangsu province), (' Hepburn makeup nail art training school to introduce ')

SELECT *
The FROM @ keyword k
WHERE the EXISTS (SELECT 1 FROM @ city c WHERE k.k eyword LIKE '%' + Arthur c. ity + '%');

CodePudding user response:

Thank you, if you want to the following as a result, how to write?

Table 1 below:

City
Jiangsu
Hubei
Shanghai
Shanxi
Nantong
Wuhan


Table 2 is as follows:

Keyword
Shanghai it training
Dark horse hui Shanghai education college
It is the best school school what school
Jiangsu it education
Where to learn good performance
Hubei wuhan Hepburn makeup nail art training school introduced

to get the following results (according to table 1 word batch matches the data in table 2)
Keyword city
Shanghai it training
Dark horse hui Shanghai education college
It is the best school school what school is NULL
It education in jiangsu jiangsu
Where to learn good performance NULL
Hubei wuhan Hepburn makeup nail art training school in wuhan
  • Related