[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Serch for terms within SQL table that exist in a second table

Posted on 2016-09-01
2
Medium Priority
?
69 Views
Last Modified: 2016-09-12
I have a table of text terms that I want to search a second table to see if any of the Text Terms in the first table exist in a description in the second table excluding itself.

For clarity purposes I have attached an excel spreadsheet that shows an example of what I'm looking for.

The first column of data is in table # 1 (tmpTextIDTable) and contains a single column of text entries labeled TextID.
Columns E and F reference table #2 (tmpTextMatchDetails) which contain two columns TextID and TextDescription.

TextId is the key field to join the two tables.

You will not that the rows marked with either yellow or green, contain a reference to one or more references to the TextID text from table 1, however references to its own TextID is excluded.

I essentially want to create a list that tells me which rows from table two have a reference to any of the textid excluding itself.

Does this make sense?

Thanks for any direction you have
TextMatch.xlsx
0
Comment
Question by:jdr0606
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Pawan Kumar earned 2000 total points
ID: 41780907
Use below approach..

Solution 1

---------------------------------------

SELECT Words.Texts Word , r.Texts Texts
FROM Words
CROSS APPLY
(
    SELECT Texts FROM Texts
)r
WHERE CHARINDEX(Words.Texts,r.Texts,0) > 0

SOLUTION 2

-------------------------------------

SELECT Words.Texts Word , r.Texts Texts
FROM Words
CROSS JOIN Texts r
WHERE CHARINDEX(Words.Texts,r.Texts,0) > 0


URL for ref --
https://msbiskills.com/2016/07/06/sql-puzzle-word-search-puzzle/


Enjoy ! Let me know in case you want me to write the exact query.. for that you need to share your table design for both the tables.
0
 

Author Comment

by:jdr0606
ID: 41794121
That gave what I needed to make it work

Thanks
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question