Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Data Fields Containing Wildcards?

Author  Topic 

why767
Starting Member

2 Posts

Posted - 2013-05-08 : 08:35:41
I have a data table that has text data fields that contain wildcards? How can I join 2 tables on a query like;

SELECT Field1

FROM Table1

LEFT JOIN Table2

ON Table1.Field1 = Table2.Field1

So if Table1.Field1 contains ‘318A__3’ and Table2.Field1 contains ‘318A003’ it would match and the query would return ‘318A003’ along with all the other fields in that record from both tables.
The 5th and 6th position of Table1.Field1 in this example have the underscore but it may not always be in the 5th and 6th position.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-08 : 09:04:36
change the join condition to
Table2.Field1 LIKE Table1.Field1
Go to Top of Page

zhulin

3 Posts

Posted - 2013-05-08 : 09:32:56
If you can share more information. So I can understand more comprehensive, I hope you getting better and better


__________________
zhulin
unspammed
Go to Top of Page

why767
Starting Member

2 Posts

Posted - 2013-05-09 : 21:21:53
Yes using LIKE instead of = worked
THANKS!
Go to Top of Page
   

- Advertisement -