Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Join Expand / Collapse
Author
Message
Posted Friday, May 2, 2014 8:30 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 8:52 AM
Points: 253, Visits: 761
I am trying to Join Two tables (A & B)
One of them has a value - IBM
another table has value IBM (Integrated)

Table A
Left Join
Table B
On A.DeviceType = B.DeviceDetail + '%'

But when I see the results
For table one I see IBM but Table B shows Null and so I cannot pull the required values.
Post #1567060
Posted Friday, May 2, 2014 8:40 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 8:38 AM
Points: 4,655, Visits: 11,125
Your question is a bit confusing and I'm not sure this is what you really want, however I think that LIKE is what you're looking for:

SELECT SomeColumns
FROM TableA
LEFT JOIN TableB
ON A.DeviceType LIKE B.DeviceDetail + '%'



--
Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
Post #1567065
Posted Friday, May 2, 2014 8:43 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 8:52 AM
Points: 253, Visits: 761
My Bad, I am using The LIKE Operator. ( Typo)
Post #1567066
Posted Friday, May 2, 2014 8:50 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 8:52 AM
Points: 253, Visits: 761
No Worries , I figured it.
The join is the other way round:)
Post #1567072
Posted Friday, May 2, 2014 8:51 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:05 PM
Points: 13,327, Visits: 12,820
So is your query ok now or do you still need help?

--edit--

Seems you were posting at the same time I was. Glad you figured it out.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1567073
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse