Thanks a lot but getting an error... can you help further?
Error is:
Msg 156, Level 15, State 1, Procedure sp_bbb_select_event_projec
Incorrect syntax near the keyword 'on'.
Main Topics
Browse All TopicsI have a table of media with the PKID called MediaID.
I have a table of OrdersDetails with a Foreign key of MediaID and PKID of EventProjectItemID
When looping through the media table I want to return ALL records in it, but I want to see if any of the MediaID's are also found in the OrderDetails table.
The MediaID may be found multiple times in the OrderDetails table - but I only care if it is in there or not (scalar or bit info is what I need).
I am currently using a left inner join, which tells me what I need, but it obviously returns more records than needed if the MediaID appears more than once in the Order Details table.
I thought about doing a scalar sub select within the main select, but I cannot figure out this would work.
Can you help?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
sure...try this:
SELECT *, existsindetail = CASE WHEN EXISTS(
SELECT 1 FROM BBB_EventProjectOrderDetai
WHERE m.EventMediaID = d.EventMediaID AND d.EventProjectOrderID = @EventProjectOrderID
) THEN 1 ELSE 0 END
FROM BBB_EventProjectMedia m
WHERE (BBB_EventProjectMedia.Eve
ORDER BY BBB_EventProjectMedia.Medi
Business Accounts
Answer for Membership
by: chapmandewPosted on 2009-01-14 at 12:56:01ID: 23377392
Select *, existsindetail = case when exists(select 1 from BBB_EventProjectOrderDetai ls d on m.EventMediaID = d.EventMediaID ANd EventMediaID AND d.EventProjectOrderID = @EventProjectOrderID
) then 1 else 0 end
From BBB_EventProjectMedia m