SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Data Fields Containing Wildcards?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

why767
Starting Member

2 Posts

Posted - 05/08/2013 :  08:35:41  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3661 Posts

Posted - 05/08/2013 :  09:04:36  Show Profile  Reply with Quote
change the join condition to
Table2.Field1 LIKE Table1.Field1
Go to Top of Page

zhulin
Starting Member

3 Posts

Posted - 05/08/2013 :  09:32:56  Show Profile  Reply with Quote
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 - 05/09/2013 :  21:21:53  Show Profile  Reply with Quote
Yes using LIKE instead of = worked
THANKS!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000