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

The Archive Base Latest Questions

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

Ok I have a sqlite db, that has roughly 100 rows. It is kind

  • 0

Ok I have a sqlite db, that has roughly 100 rows. It is kind of a strange thing that I’m trying to do, but I need to insert a new row between each of the existing rows.

I have been trying to use the Insert statement as follows, but haven’t had any luck:

insert into t1(column1) values("hello") where id%2 == 0

So I’m basically trying to use the %-operator to tell me if the id is even or odd. For every even id number, I’d like to insert a new row.

What am I missing? What can I do differently? How can I insert a new row into every other row and have the index updated as well?

Thanks

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

    Your question assumes that the rows have some kind of built-in order to them, and that you can insert rows between other rows. That’s not true.

    It is true that rows have an order on disk, and that the id column is usually assigned in order, but that’s an implementation detail. When you perform a query, the database is free to return the rows in any order it chooses, unless you specify what you want with an ORDER BY clause.

    Now, I’m assuming what you really want is to insert rows between the existing rows in id order. One way to get what you want would look like this:

    UPDATE t1 SET id = id * 2
    INSERT INTO t1 (id, column) SELECT id+1, "hello" FROM t1
    

    The UPDATE would double the ids of all the existing rows (so 1,2,3 becomes 2,4,6); then the INSERT would perform a query on t1 and use the result to insert a new set of rows with id values one more than the existing rows (so 2,4,6 becomes 3,5,7).

    I haven’t tested the above statements, so I don’t know if they would work or if they require some extra trickery (like a temporary table) since we are querying and updating the same table in one statement. Also I may have made a syntax error.

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

Sidebar

Related Questions

I have a SQLite DB that has people LastName, FirstName, Department and I need
In my app I have SQLite database that has one table with date rows
I have an SQLite table that contains a BLOB I need to do a
I have a Sqlite database that has a table consisting of company information (Companies)
I have an sqlite database that has a blob column with blob data. I
I have a sqlite db that at the moment has few tables where the
I have an iphone app that has a sqlite db, mapped to core data.
I have an SQLite Database with 5000 rows that is loaded into a tableview.
I have a SQLite backed database of roughly 4000 rows, connected to Core Data.
I have a SQLite database that has pretty intensive repeated reads and occasional writes.

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.