When running the following query
UPDATE Invoices
SET PaymentTotal = 1
FROM Vendors
WHERE Vendors.VendorID = 34 -- true for some row
SQL Server updates all records in Invoices. However, when the condition does not match any row in the Vendors table:
UPDATE Invoices
SET PaymentTotal = 1
FROM Vendors
WHERE Vendors.VendorID = -34 -- false for all rows
no rows get updated. WHY?
Edit: This is a COMPLETELY academic question and I understand that this is not the ideal way to write queries.
Your original query:
is equivalent to:
the cross join returns the product of the two sets and when
vendorsis reduced to an empty set with the criteriav.vendorid = -34then the resulting set is empty because anything multiplied by zero is zero.