Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Query - add a condition on a left join

Posted on 2008-11-13
2
Medium Priority
?
225 Views
Last Modified: 2012-05-05
I have the following query:

----

SELECT * FROM activities_misc a
left join AttachmentLinks as b on a.act_misc_id = b.Object_id
left join Attachments as c on c.attachment_id = b.attachment_id
WHERE Firmid = 2 AND Caseid = 10062
ORDER BY act_misc_id desc

--

I want to do the first join to Attachmentlinks ONLY when b.Object_type = 'receipt'

How would the syntax be ?

A
0
Comment
Question by:Aleks
2 Comments
 
LVL 8

Accepted Solution

by:
i2mental earned 1000 total points
ID: 22953352
SELECT * FROM activities_misc a
left join AttachmentLinks as b on a.act_misc_id = b.Object_id and  b.Object_type = 'receipt'
left join Attachments as c on c.attachment_id = b.attachment_id
WHERE Firmid = 2 AND Caseid = 10062
ORDER BY act_misc_id desc
0
 

Author Comment

by:Aleks
ID: 22953417
thx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

564 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