Solved

Join using a 'like'

Posted on 2012-03-30
2
269 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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

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 …
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.

856 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