• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

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??

0
zeeshanhayder
Asked:
zeeshanhayder
1 Solution
 
moseackCommented:
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 ThakurCommented:
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now