MikeMCSD
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
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
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
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)
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
but I always forget how to code sql when I haven't done it for a long time.
thanks
you cant update a column on the nop table if the assocaited data doest exist...
do you want it inserted?