Solved

very complicated query for detecting previously selected item

Posted on 2009-05-07
2
139 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL to Update Table Dynamically 2 61
passing parameter in sql procedure 9 67
How to import SQL 2000 database to SQL 2014 5 156
How to simplify my SQL statement? 14 55
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…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

680 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