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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:04:20+00:00 2026-05-23T15:04:20+00:00

I’m no SQL expert, but have a bug in an iPhone app where and

  • 0

I’m no SQL expert, but have a bug in an iPhone app where and UPDATE statement has no effect on the db.
I have been using the SQLlite manger plugin for FireFox to try dbug by repeatedly amending and running the UPDATE on the db. I also ran the statement thorough and SQL Validator which said it complied to the core SQL standard.

Can you spot anything wrong with the statement given below?

UPDATE sections
SET
    title = 'What is acne ? ABC',
    text = 'Pus on your face',
    created = '2010-03-10 18:46:55',
    modified = '2011-07-04 17:38:44',
    position = 1,
    condition_id = 4
WHERE id = 10;
  • 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-23T15:04:20+00:00Added an answer on May 23, 2026 at 3:04 pm

    There is some confusion and inconsistency in the way SQLite and the various implementations by Mozilla, Google, Adobe, and others handle numeric primary keys in databases whose tables were created outside of these implementations and where the primary keys were defined as an integer type but not as “INTEGER” [verbatim] — that is, they were defined as INT or INT16 or INT32 etc.

            INTEGER PRIMARY KEY in mothership SQLite is an alias for the rowid.
            INT PRIMARY KEY in mothership SQLite is not an alias for the rowid.
    

    A consortium member (or any implementor) may or may not follow this rule. (SQLite is in the public domain, of course.)

    See section 2.0 here: http://www.sqlite.org/datatypes.html

    and see section on RowId and Primary Key here: http://www.sqlite.org/lang_createtable.html#rowid

    A PRIMARY KEY column only becomes an integer primary key if the
    declared type name is exactly “INTEGER”. Other integer type names like
    “INT” or “BIGINT” or “SHORT INTEGER” or “UNSIGNED INTEGER” causes the
    primary key column to behave as an ordinary table column with integer
    affinity and a unique index, not as an alias for the rowid. [emphasis
    added]

    An implementor who does not follow the rule might not have even been aware that they were breaking the rule in the first place, since it is a “gotcha” arcane sort of rule. Anyway, what this means practically is that one implementation may treat a supplied value as an alias for the rowid and another implementation might not. If given the value 10, one might retrieve the tuple whose rowid = 10 and one might retrieve the tuple where the specified column’s value = 10. This, of course, leads to spurious results in queries — and they might look like perfectly good and plausible results but they are dead wrong.

    Consider the following simple test: using flagship SQLite’s utilities, not those provided by one of the implementors, execute the following DDL and DML statements; then, in your implementation, open the database and execute the DML statements again to compare the DML results:

            CREATE TABLE TEST
            ("id" INT PRIMARY KEY, "name" text)  -- ** NOTE "INT" not "INTEGER"
    
            INSERT INTO TEST
            (id, name)
            VALUES
            (7,'seven')
    
    
             ** *** N.B. THE ROWID OF THE ROW INSERTED ABOVE =  1  *** **
    
    
            select rowid, id, name from test
    
           result:  1 | 7 | seven
    
    
            select * from TEST 
    
            result:  7 | seven
    
    
            select * from TEST where id = 7
    
            result:  ?????  [ymmv]
    
    
    
            select * from TEST where id = 1
    
    
            result: ?????  [ymmv]
    

    Depending on how the specific implementation treats an INT primary key the third select statement above (select * from TEST where id = 7) may return one row or it may return nothing!

    If the implementation treats the INT PK as an alias for the row id, well, there is no row whose rowid = 7, and so it will return nothing. If the implementation treats the INT PK as a normal value, it will find the row.

    Now, if you were to insert more rows into table TEST, you would eventually create a row whose rowid = 7. In one of these wayward implementations, when you use this where-clause — where id = 7 — you might think you were addressing the tuple whose id=7, but you’d actually be addressing the tuple whose rowid=7. You would get the wrong tuple and you might not realize it. Consider the possibilities when joining a child table to a parent table: the child table contains foreign key value of 7. What tuple does an inner join return from the parent table? It depends on whether the implementation honors the distinction between INT and INTEGER primary keys.

    Last year, I documented this thoroughly for Adobe AIR, BTW, and also reported it on the SQLite news group. It is possible that some implementations have changed the behavior in the interim.

    When creating SQLite tables, it is best to use INTEGER [verbatim] for primary keys, not any of the other recognized int types.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.