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 6544917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:31:24+00:00 2026-05-25T11:31:24+00:00

I ran the following query, which should have had a where clause but I

  • 0

I ran the following query, which should have had a where clause but I forgot to add it:

UPDATE
tblFormElementInstances as fei
JOIN
tblFormElements as fe using(intFormElementId)
SET
fei.intStep = 1
AND
fei.intDivisionId = 1 OR fei.intDivisionId IS NULL);

MySQL returned the following message:

–Query OK, 42 rows affected (0.06 sec)
–Rows matched: 94 Changed: 42 Warnings: 0

I would have expected it to throw a syntax error, but it didn’t. Additionally there are 96 rows in that table, with differing intDivisionIds (i.e. not just 1 or NULL), which suggests that some filtering was done by MySQL (rows matched = 94).

Also, intStep was actually changed to 0, not 1.

Does anyone know:

1) Why this query worked at all?
2) Why it changed intStep to 0 and not 1?
3) Why it didn’t match all 96?

(The changed count of 42 is because some rows already had intStep = 1.)

  • 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-05-25T11:31:24+00:00Added an answer on May 25, 2026 at 11:31 am

    It works without a syntax error because 1 AND <expr> is a valid expression.

    You set intStep to this expression (I have added parentheses to show precedence):

    SET intStep = ((1 AND (fei.intDivisionId = 1)) OR (fei.intDivisionId IS NULL))
    

    That’s a boolean expression that is either 0 or 1, and so it changes some rows to 0 and some rows to 1. It changes to 0 if intDivisionId is not 1, and if intDivisionId is not null.

    I would guess you have 96 rows in tblFormElementInstances, but only 94 of these rows have a matching row in tblFormElements. The JOIN means only matching rows are eligible for the UPDATE.

    Try this query to test this theory, I bet it’ll return 94:

    SELECT COUNT(*) FROM tblFormElementInstances as fei
    JOIN tblFormElements as fe using(intFormElementId)
    

    @Jason McCreary makes a good observation that you have an imbalanced parenthesis at the end of your example. That should result in a syntax error. Since you say you didn’t get a syntax error, I assume that parenthesis is included in your example by mistake.

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

Sidebar

Related Questions

I have the following query that I ran on my database to remove some
I have the following ActiveRecord query. It ran fine when the number of messages
Although I have been able to see the last ran query which is a
I have the following query which is giving me an ORA-00935 missing expression error,
I ran into an interesting error with the following LiNQ query using LiNQPad and
I ran the following code, but nothing came up on the console.... #include <stdio.h>
I'm currently preparing a major Program-Update and ran into following problem: I've got a
We have few components like libraries dlls When initially created I ran the following
Today I ran into the following problem with NUnit. I have a class, that
I have an SQL query (generated by LINQ to Entities) which is roughly like

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.