Link to home
Start Free TrialLog in
Avatar of MikeMCSD
MikeMCSDFlag for United States of America

asked on

Help with Query

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
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

please revisit the question...

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

do you want it inserted?
Avatar of MikeMCSD

ASKER

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
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)
ASKER CERTIFIED SOLUTION
Avatar of Ramkisan Jagtap
Ramkisan Jagtap
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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