Solved

Join using a 'like'

Posted on 2012-03-30
2
266 Views
Last Modified: 2012-03-30
I need to find the best way to join another table using a like in the join.

What I have is a query that has a inner join, and left outer join and it is working.
The first part of the query (with the inner join) joins 2 tables together to look for and calculate device events and their duration. The outer join pulls in any event messages if any.

Now what I need to do is join yet another table if the device name appears in one of two fields in another table. So if the device name from the first query appears somewhere in the summary or description fields in the last joined table I need to pull in additional information.

So what I am looking for a way to do this is like

...
outer left join HelpDesk HPD
.. if QueryA.DeviceName appears somewhere in the HPD Sumamry or Description fields


Possible?
0
Comment
Question by:edrz01
2 Comments
 
LVL 8

Accepted Solution

by:
gpizzuto earned 500 total points
Comment Utility
outer left join HelpDesk HPD
ON (NPD.Summary+NPD.Description like '%'+QueryA.DeviceName+'%')

Probably you need to use ISNULL(,) both for Summary and for Description
0
 

Author Comment

by:edrz01
Comment Utility
gpizzuto, Thanks for the idea. I had to also include my date ranges as it was trying to look at all records in the other joined table. Now that I did that the query works!

Thank you.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now