Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:58:03+00:00 2026-06-15T08:58:03+00:00

When running the following query UPDATE Invoices SET PaymentTotal = 1 FROM Vendors WHERE

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:58:04+00:00Added an answer on June 15, 2026 at 8:58 am

    Your original query:

    UPDATE Invoices
    SET PaymentTotal = 1
    FROM Vendors
    WHERE Vendors.VendorID = 34
    

    is equivalent to:

    update i set paymenttotal = 1
    from vendors v
    cross join invoices i
    where v.vendorid = 34
    

    the cross join returns the product of the two sets and when vendors is reduced to an empty set with the criteria v.vendorid = -34 then the resulting set is empty because anything multiplied by zero is zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running the following UPDATE query and having no succes: $sql=UPDATE users SET firstname='.$_GET['fn'].',lastname='.$_GET['ln'].',email='.$_GET['emadd'].'
Running the following query in SQL Server Management Studio gives the error below. update
Presently troubleshooting a problem where running this SQL query: UPDATE tblBenchmarkData SET OriginalValue =
I have the following query. UPDATE t SET UnitsSold = sub.UnitsSold, FROM dbo.table1 t
I am running following query. SELECT T1.C1, T2.C2..., IF( T1.C1<>T2.C1,Changed,1) AS NewColumn From T1
I am running following query.. Select T1.* from T1 LEFT JOIN T2 ON T1.C1
I am running following query in SQL*Plus CREATE TABLE tbl_audit_trail ( id NUMBER(11) NOT
I tried running the following query to restore a database: restore database myDatabase from
I'm currently running the following query: SELECT * from people WHERE id = 4;
Using phpMyAdmin and running the following query I get 19 registers: SELECT * FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.