?
Solved

Join using a 'like'

Posted on 2012-03-30
2
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
gpizzuto earned 2000 total points
ID: 37786645
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
ID: 37786782
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

764 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