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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:50:33+00:00 2026-05-25T22:50:33+00:00

I have a sqlite database with a table named Achievements, it stores whether certain

  • 0

I have a sqlite database with a table named Achievements, it stores whether certain achievements have been met in a simple quiz I am building (iphone project to learn objective-c). The table structure is:

ID    Name           Completed  
=============================
1     FiveInARow     0  
2     TenInARow      0  
3     AllCorrect     0  
4     UnderASecond   0  
5     AllCompleted   0  

The ID is the primary key, Name is a VARCHAR and Completed is BOOL (0 for false and 1 for true).

I am trying to add a trigger onto the update statements of this table, such that when a Completed column is set to 1 (i.e. achievement completed – this is the only update that will happen on the table) there will be a calculation to see whether all of the other achievements have been completed and if so also update the AllCompleted achievement (ID 5) to 1.

The trigger I created is:
CREATE TRIGGER "checkAllAchievements" AFTER UPDATE ON "Achievements"
WHEN (Select SUM(Completed) from Achievements) = (Select COUNT(Completed) -1 from Achievements)
BEGIN UPDATE Achievements SET Completed = 1 WHERE Name= 'AllCompleted';

So what I am trying to do is take the sum of the completed row and compare it to the total count minus 1, if they match then it means that all achievements apart from the AllCompleted achievement are achieved so we can also set that to true. The trigger gets created fine.

Now on to the problem – When I attempt to update the table with the following statement

UPDATE Achievements SET Completed = 1 WHERE ID = 1

I receive the error message “No such Column Completed”.

Am I trying to do something that is fundamentally wrong? Is it not possible for me to achieve this using a trigger? Any advice?

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-25T22:50:34+00:00Added an answer on May 25, 2026 at 10:50 pm

    Double check that you spelled everything exactly as it is in the database. In your example, you state the table name is “Achievements” however reference “Achievement” in two places.

    Fixing that should solve your issue. Final SQL is as follows:

    CREATE TRIGGER "checkAllAchievements" 
    AFTER UPDATE ON Achievements
    WHEN (SELECT SUM(Completed) FROM Achievements) = (SELECT COUNT(Completed)-1 FROM Achievements)
    BEGIN 
      UPDATE Achievements SET Completed=1 WHERE Name='AllCompleted';
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQLite database with a simple table of Persons. Each row represents
I have table named lantable in sqlite database where there is a column named
I have a DataTable which I want to save to a SQLite Database Table.
i have created a table named Ord in SQlite and the schema is :
I have a Sqlite database that has a table consisting of company information (Companies)
I created a SQLite database via SQLiteManager. I have a table called Envelopes, and
I have a SQLite database with cyrillic rows in it. For example: CREATE TABLE
In my application I have a sqlite database that looks like this: CREATE TABLE
I have a table named coords with the following columns |name|lat|lon|und| import sqlite3 database
How to count the number of rows in an SQLite database table? I have

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.