Solved

Help with Query

Posted on 2011-09-26
5
199 Views
Last Modified: 2012-05-12
If the field "SKU" does not exist in the "Nop_ProductVariant"  table
but exist in the "Query" table based on the "[Item ID]" field,
I want to set the "DisableBuyButton" field to 1.

UPDATE Nop_ProductVariant
SET DisableBuyButton = 1

SELECT [Item ID]
FROM [Query]

thanks
0
Comment
Question by:MikeMCSD
5 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
Comment Utility
please revisit the question...

you cant update a column on the nop table if the assocaited data doest exist...

do you want it inserted?
0
 
LVL 16

Author Comment

by:MikeMCSD
Comment Utility
I'm a little confused here myself now . . . Let me break it down :

I want to compare the 2 tables "Nop_ProductVariant"  and "Query".

If the "Nop_ProductVariant"  table has no match for the SKU field compared to the  [Item ID] field in the "Query" table,
I want to set DisableBuyButton = 1 in Nop table.
Something like this :
"Query" table  has [Item ID] field with a value "888-UHE"
"Nop_ProductVariant"  table's SKU field has no match for that value so I set  DisableBuyButton = 1
0
 
LVL 7

Expert Comment

by:Jacobfw
Comment Utility
Something like this?

insert into Nop_ProductVariant
select [Item ID], 1
from   Query Q1
where not exists (select 1
                             from Nop_ProductVariant
                             where  [Item ID] = Q1.SKU)
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
Comment Utility
please execute query as below

update Nop_productVarient set  DisableBuyButton=1 where SKU not in(select ItemID from Query)
0
 
LVL 16

Author Comment

by:MikeMCSD
Comment Utility
yes ram, that was exactly what I was thinking of
but I always forget how to code sql when I haven't done it for a long time.
thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now