Solved

very complicated query for detecting previously selected item

Posted on 2009-05-07
2
137 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
2 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Select * from 6 41
Query - which index being used? 2 53
Why is the output of this function is like this? 4 36
kill process lock Sql server 9 54
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 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