Solved

Help with Query

Posted on 2011-09-26
5
202 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
[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
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

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

740 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