我正在开发使用C#的ASP.NET Web表单应用程序,我在SQL Server中的两个表,terms
和descriptions
。
CREATE TABLE Terms
(
[TermId] [int],
[TermLable] [varchar](50)
);
CREATE TABLE Descriptions
(
[DescriptionId] [int],
[Descriptions] [varchar](MAX)
);
第一个表包括术语(超过 10K),例如
1 JAVA
2 C++
3 ASP.NET
4 Linux
5 web development
6 programming language
第二个表包括以下描述:
1 Java is the one of the most popular programming languages in the world today. It works on any platform (Windows, Mac, Linux, etc), and is the core language used in developing Android apps. It's a great first language for any aspiring programmer, so whether you want to program Android apps, web apps, or simply learn the foundational skills that all programmers use, this course is a great place to start!
2 This course teaches C++ to students already familiar with a programming language. Students will learn how to use header files, control flow, functions, classes.
我想创建在每个描述中搜索并从第一个表中找到匹配项的查询。所以结果将是这样的:
第一句中的匹配项:
JAVA
Linux
第二句中的匹配项:
C++
programming language
我真的试图想出一种使用 select %like% 来做到这一点的方法,但这仅适用于特定术语的我..我无法想出一种方法来包含列中的所有这些术语。
最好的方法是什么?
您可以使用 JOIN:
SELECT *
FROM Descriptions d
JOIN Terms t
ON d.descriptions LIKE '%' + t.TermLable + '%'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句