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

The Archive Base Latest Questions

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

I have a query UPDATE Table_1 SET Col1=’Y’ WHERE ROWID IN ( select ROWID

  • 0

I have a query

UPDATE Table_1 SET Col1='Y' WHERE ROWID IN (
    select ROWID from (
        SELECT BUS_ID,
               row_number() over (partition by BUS_ID order by BUS_ID) dupe_count,
               rowid
        from Table_1
        WHERE col2 <> 1
          AND col3 <> 1
        order by dbms_random.value 
    ) ft
    where ft.dupe_count = 1
      AND ROWNUM <= 1000 
);

updates only 1000 rows in table Table_1.

But if i write

 UPDATE Table_1 SET Col1='Y' WHERE ROWID IN (
     select ROWID from (
         SELECT BUS_ID,
                row_number() over (partition by BUS_ID order by BUS_ID) dupe_count,
                rowid
         from Table_1
         WHERE col2 <> 1
           AND col3 <> 1
         order by dbms_random.value 
     ) ft
     where ft.dupe_count = 1
       and Table_1.BUS_ID = ft.BUS_ID
       AND ROWNUM <= 1000 
);

it updates all rows of the table irrespective of RoWNUM <= 1000 i.e if i add

Table_1.BUS_ID = ft.BUS_ID

then it updates all rows that satisfies col2<> 1 AND col3<> 1 and ft.dupe_count=1.
The table is having following structure:

BUS_ID | col1 | col2 | col3
     1 |      |   0  | 0
     2 |      |   0  | 0
     1 |      |   0  | 0
     3 |      |   1  | 1.

Any idea why is it happening.Please help.

  • 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-25T06:25:32+00:00Added an answer on May 25, 2026 at 6:25 am

    Niraj,

    An ordinary subquery is evaluated for each table. A correlated subquery is evaluated for each row. And you have made the subquery in your second update statement correlated with the line Table_1.BUS_ID = ft.BUS_ID. And if it evaluates for each row, then it will always satisfy the ROWNUM <= 1000 predicate.

    Regards,
    Rob.

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

Sidebar

Related Questions

I have a query: UPDATE table_1 set field_1 = 1 where field_2 IN (SELECT
I have an update query like following: update table TABLE1 set COL1 = 'X'
I have the following sql query: UPDATE (SELECT * FROM table_A INNER JOIN table_B
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have this SQL update query: UPDATE table1 SET table1.field1 = 1 WHERE table1.id
I have a query that is ExcelQuery = Update [Sheet1$] +set CITIZEN_ID = #
I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have this query: UPDATE table_name SET field_1 = field_1 +100, field_2 = field_2
I have a query that takes 2minutes to count from table A and update
I have the following query: UPDATE #Temp_SessionItem SET [Status] = CASE WHEN ([AddressFK] IS

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.