Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help with Query

Posted on 2011-09-26
5
Medium Priority
?
207 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

609 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