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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:47:59+00:00 2026-05-31T16:47:59+00:00

I have a table with 4 columns. The first column is unique for each

  • 0

I have a table with 4 columns. The first column is unique for each row, but it’s a string (URL format).
I want to update my table, but instead of using “WHERE”, I want to update the rows in order.
The first query will update the first row, the second query updates the second row and so on.

What’s the SQL code for that? I’m using Sqlite.

Edit: My table schema

CREATE table (
url varchar(150),
views int(5),
clicks int(5)
)

Edit2: What I’m doing right now is a loop of SQL queries

update table set views = 5, click = 10 where url = “http://someurl.com”;

There is around 4 million records in the database. It’s taking around 16 seconds in my server to make the update. Since the loop update the row in order, so the first query update the first row; I’m thinking if updating the rows in order could be faster than using the WHERE clause which needs to browse 4 million rows.

  • 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-31T16:48:00+00:00Added an answer on May 31, 2026 at 4:48 pm

    You can’t do what you want without using WHERE as this is the only way to select rows from a table for reading, updating or deleting. So you will want to use:

    UPDATE table SET url = ... WHERE url = '<whatever>'
    

    HOWEVER… SqlLite has an extra feature – the autogenerated column, ROWID. You can use this column in queries. You don’t see this data by default, so if you want the data within it you need to explicitly request it, e.g:

    SELECT ROWID, * FROM table
    

    What this means is that you may be able to do what you want referencing this column directly:

    UPDATE table SET url = ... WHERE ROWID = 1
    

    you still need to use the WHERE clause, but this allows you to access the rows in insert order without doing anything else.

    CAVEAT
    ROWID effectively stores the INSERT order of the rows. If you delete rows from the table, the ROWIDs for remaining rows will NOT change – hence it is possible to have gaps in the ROWID sequence. This is by design and there is no workaround short of re-creating the table and re-populating the data.

    PORTABILITY
    Note that this only applies to SQLite – you may not be able to do the same thing with other SQL engines should you ever need to port this. It would be MUCH better to add an EXPLICIT auto-number column (aka an IDENTITY field) that you can use and manage.

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

Sidebar

Related Questions

I have a 2 column table with 2 IDs, each pair being unique. I
Suppose I have two columns in a table that represents a graph, the first
I have table with 3 columns A B C. I want to select *
I have a table called Table with columns: ID (int, primary key, clustered, unique
Let's say I have table TabA with columns: col1 - primary key (but not
I have three columns in my table - company_name, first_name, last_name . In the
The table columns have the data type BLOB and CLOB. What are the corresponding
I have a table with columns ID, DateStamp and the ID need not be
I have a table with columns Index, Date where an Index may have multiple
I have a table with columns 'id', 'name', 'value', 'uniqueConst' in both databases. Now

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.