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

  • Home
  • SEARCH
  • 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 9235857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:09:04+00:00 2026-06-18T07:09:04+00:00

This query result every time differently: update product_models set category_id = (select id from

  • 0

This query result every time differently:

update product_models
  set category_id = (select id from categories order by RAND() limit 1)

Different counts repeatedly:
884 record(s) were affected
878 record(s) were affected
877 record(s) were affected
892 record(s) were affected
893 record(s) were affected
883 record(s) were affected
885 record(s) were affected

How come?

extra info


in the categories there are 22 rows
in the product models – 900
in the products – 600
the sub query has no conditions, no joins and always return a single row.
the main query also has no conditions or joins, so it should also return a fixed number.

So, every execution should return 900 product models, and each p.m should be updated by the subquery

  • 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-18T07:09:06+00:00Added an answer on June 18, 2026 at 7:09 am

    Assuming that each time that you run the query the data is identical, the cause is that rows aren’t counted as affected if the data doesn’t change. So if 5 is selected as the random ID, rows that already have 5 for the category_id aren’t counted.

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

Sidebar

Related Questions

Can anyone explain why this query returns an empty result. SELECT * FROM (`bookmarks`)
I have this query which returns a result set with Date(column) as nvarchar datatype.
How to apply GROUP_CONCAT in this query? Query SELECT WEEK(cpd.added_date) AS week_no,COUNT(cpd.result) AS death_count
Normally when I want to query large result set using Mysql I write this
I want to execute a query like this var result = from entry in
please take a look of this query: SELECT DATE(datetime), COUNT(1) as numVisits FROM .table_stats.
I want to optimize this query **SELECT * FROM Users WHERE Active = 1
Hi I have this Query and I'm getting an empty result, Anyone see anything
This would be an example of database table: PHP script should limit query result
I'm gettintg crazy with the result of this query This query returns 29.970 rows

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.