?
Solved

very complicated query for detecting previously selected item

Posted on 2009-05-07
2
Medium Priority
?
143 Views
Last Modified: 2012-05-06
hi
i have to prevent an item to reappear based on the preconditions.
when user create a schedule the gameid is going inside the DayCountGame table

INSERT DayCountGame Values(@sVideoItemID,1,@gameid,@SlotStartTime,@ShowId)

when user next create the schedule i want to block the game to reappear in the same show where showid is matched. @showid is a dynamic parameter

i have done the join but i am not sure how can i add the condition if @showid = GB.showid
then apply this condition AND GB.[GameID]  is null

LEFT JOIN DayCountGame GB
ON VI.[GameID] = GB.[GameID]

AND GB.[GameID]  is null



CREATE TABLE [dbo].[DayCountGame](
	[VideoItemID] [int] NOT NULL,
	[SelectCount] [smallint] NOT NULL,
	[GameID] [int] NULL,
	[sd] [datetime] NOT NULL,
	[ShowID] [int] NULL
) ON [PRIMARY]

Open in new window

table.GIF
0
Comment
Question by:mattibutt
[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 37

Accepted Solution

by:
momi_sabag earned 2000 total points
ID: 24324803
maybe

LEFT JOIN DayCountGame GB
ON VI.[GameID] = GB.[GameID]
where (@showid = GB.showid and GB.[GameID]  is null)
or @showid <> GB.showid
0
 
LVL 11

Author Closing Comment

by:mattibutt
ID: 31578956
thanks for your reply i have ressolved this problem
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
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…

649 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