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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:54:03+00:00 2026-06-08T02:54:03+00:00

I have a SQLite database with table myTable and columns id , posX ,

  • 0

I have a SQLite database with table myTable and columns id, posX, posY. The number of rows changes constantly (might increase or decrease). If I know the value of id for each row, and the number of rows, can I perform a single SQL query to update all of the posX and posY fields with different values according to the id?

For example:

---------------------
myTable:

id   posX    posY

1      35     565
3      89     224
6      11     456
14     87     475
---------------------

SQL query pseudocode:

UPDATE myTable SET posX[id] = @arrayX[id], posY[id] = @arrayY[id] "

@arrayX and @arrayY are arrays which store new values for the posX and posY fields.

If, for example, arrayX and arrayY contain the following values:

arrayX = { 20, 30, 40, 50 }
arrayY = { 100, 200, 300, 400 }

… then the database after the query should look like this:

---------------------
myTable:

id   posX    posY

1      20     100
3      30     200
6      40     300
14     50     400
---------------------

Is this possible? I’m updating one row per query right now, but it’s going to take hundreds of queries as the row count increases. I’m doing all this in AIR by the way.

  • 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-08T02:54:05+00:00Added an answer on June 8, 2026 at 2:54 am

    There’s a couple of ways to accomplish this decently efficiently.

    First –
    If possible, you can do some sort of bulk insert to a temporary table. This depends somewhat on your RDBMS/host language, but at worst this can be accomplished with a simple dynamic SQL (using a VALUES() clause), and then a standard update-from-another-table. Most systems provide utilities for bulk load, though

    Second –
    And this is somewhat RDBMS dependent as well, you could construct a dynamic update statement. In this case, where the VALUES(...) clause inside the CTE has been created on-the-fly:

    WITH Tmp(id, px, py) AS (VALUES(id1, newsPosX1, newPosY1), 
                                   (id2, newsPosX2, newPosY2),
                                   ......................... ,
                                   (idN, newsPosXN, newPosYN))
    
    UPDATE TableToUpdate SET posX = (SELECT px
                                     FROM Tmp
                                     WHERE TableToUpdate.id = Tmp.id),
                             posY = (SELECT py
                                     FROM Tmp
                                     WHERE TableToUpdate.id = Tmp.id)
    
    
    WHERE id IN (SELECT id
                 FROM Tmp)
    

    (According to the documentation, this should be valid SQLite syntax, but I can’t get it to work in a fiddle)

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

Sidebar

Related Questions

How to count the number of rows in an SQLite database table? I have
I have an SQLite database with a virtual table myTable created using FTS4, with
In my app I have SQLite database that has one table with date rows
I have a DataTable which I want to save to a SQLite Database Table.
In this example we have 3 related tables on a SQLite database: CREATE TABLE
i have a table in sqlite database like following. id status ============= x 0
I have a table in SQLite database of Android which has a column RANK
I have a table in a SQLite database with multiple key fields (lang and
I'm using the Firefox sqlite manager addon and I have a database table named
I have a SQLite database with with just over 6,000 rows of addresses in

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.