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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:23:39+00:00 2026-05-11T22:23:39+00:00

Using SQLite I need to copy nearly all of an existing row from a

  • 0

Using SQLite I need to copy nearly all of an existing row from a table, make a change to a single column, and insert the new row into the table. Something roughly like

INSERT INTO $tablename (c1, c2, ... , cn) 
    SELECT (c1, c2, ... , cn) FROM $tablenam

I tried substituting a some value ci into the the list of SELECT columns. This works if the value is a float or an integer, but not if it is a string. If the value is a string, SQLite interprets it as a column name, which naturally doesn’t exist and I get an error.

I can write code to perform this operation, but I was hoping to do it in one query.

I am currently coding in Tcl.

  • 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-11T22:23:39+00:00Added an answer on May 11, 2026 at 10:23 pm

    You mean this doesn’t work?

    INSERT INTO $tablename (c1, c2, ... , cn)
        SELECT (c1, c2, ..., "othervalue", ... , cn) FROM $tablename
    

    How are you constructing your query?

    pseudocode e.g. this won’t work as othervalue is interpreted as columnname

    dothquery("INSERT INTO $tablename (c1, c2, ... , cn)
            SELECT (c1, c2, ..., othervalue, ... , cn) FROM $tablename")
    

    while this works, because the " around othervalue are included in escaped format and then sqllite should recognize it as expression not anymore as columnname

    dothquery("INSERT INTO $tablename (c1, c2, ... , cn)
            SELECT (c1, c2, ..., \"othervalue\", ... , cn) FROM $tablename")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using sqlite with python. When i insert into table A i need
I'm using SQLite, and I need to do the following: SELECT * FROM fruit
Using SQLite from .net, Is there a way to access the .dump command or
What's the best way to get the last inserted id using sqlite from Java?
I'm using sqlite with python. I'm implementing the POP3 protocol. I have a table
I'm using sqlite as my database. I need a attribute to be limited to
When using sqlite in iOS, when to do finalize statement ? Do I need
I'm creating a database using SQLite 3. Many of my fields are gonna need
I would like examine androids internal database files using a sqlite browser. From my
I need to mass populate my SQLite database — ideally using a script rather

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.