Solved

Help with Query

Posted on 2011-09-26
5
201 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
ID: 36600641
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
ID: 36600751
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
ID: 36600883
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
ID: 36600931
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
ID: 36601060
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

816 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

6 Experts available now in Live!

Get 1:1 Help Now