C# Matched Wildcard?? How to Find


Hellooo

I have two tables. One contains patterns and other contain raw data.

Table_A contains data
Table_B contains Patterns

Select * from Table_A where namea in
(Select '%'+nameb+'%' from Table_B)

I m trying to concatenate nameb with '%' so that it will be used
as wild card for searching in namea.

How can i find which nameb contains within namea??

zeeshanhayderAsked:
Who is Participating?
 
Refael AckermannConnect With a Mentor Commented:
This is obviously an SQL question, but I'll give it a try.
Be aware than the concat syntax is Databe specific (e.g. '+' for MsSql or '&' for Access)
You can cross the data and the patterns, and then test for a match (with like):

SELECT Table_A.data AS data, '%' + Table_B.pattern + '%' AS pattern
FROM Table_A CROSS JOIN Table_B
WHERE data LIKE pattern;

Open in new window

0
 
Anurag ThakurTechnical ManagerCommented:
what do you mean by patters - are they simple strings or Regular Expression Patterns?
0
 
zeeshanhayderAuthor Commented:
Well Moseack your answer was sumwhat correct.

Slight modification is needed
Following SQL statement worked for Me
SELECT Table_A.data AS data, Table_B.pattern as pattern
FROM Table_A CROSS JOIN Table_B
WHERE Table_A.data LIKE '%' + Table_B.pattern + '%';

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.