`Trouble encountered while updating MySQL query and SQLite`

Take a look at my table:

id |    les_mo_id      |    les_comp     |    les_ch_comp
.1.|...................|........0....... |...................
.2.|........1..........|.................|.........1.........
.3.|........1..........|.................|.........1.........
.4.|...................|........0....... |...................
.5.|........4..........|.................|.........2.........
.6.|........4..........|.................|.........1.........
.7.|...................|........0........|...................
.8.|........7..........|.................|.........1.........
.9.|........7..........|.................|.........4.........

I'm struggling to figure out how to set up a query to update the 'les_comp' column in line with my new learning progress.

The task involves updating the columns 'les_comp' by calculating the sum of 'les_ch_comp' values where les_mo_id = 1.

This is the SQL query I've come up with so far:

UPDATE base_app SET les_comp = (SELECT SUM(les_ch_comp) WHERE les_mo_id = "1") WHERE id = "1";

Answer №1

You need to include FROM in your query. Here's a possible update:

UPDATE base_app SET lesson_complete = (SELECT SUM(lesson_child_complete) FROM 
base_app WHERE lesson_mother_id = "1") WHERE id = "1"

Answer №2

Following the recommendation of UUeerdo:

Apply this UPDATE statement to the base_app table: SET les_comp = (SELECT SUM(les_ch_comp) FROM base_app WHERE les_mo_id = "1") WHERE id = "1"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Save user sessions in a database using node.js, express, and mongoose-auth

I have a question about authentication and sessions in node.js. So, I've set up authentication using express.js and mongoose-auth with mongodb: app.use(express.cookieParser()); app.use(express.session({ secret: 'esoognom'})); app.use(auth. ...

Tips for sending a variable to the onclick function within an HTML element

Currently, I am utilizing the tabulator library to generate tables based on json data. I am attempting to insert a button into a cell using a custom cell formatter. Below is the approach I am taking: var graphButton = function(cell, formatterParams, onRe ...

Pressing the enter key within Material UI Autocomplete will allow you to quickly create new

Wouldn't it be great if Autocomplete in material ui could do this: wertarbyte Imagine being able to insert text (string) without the need for a list of elements to select from. This means that the noOptions message shouldn't appear, and instead ...

Unable to properly zoom in on an image within an iframe in Internet Explorer and Google Chrome

My image zoom functionality works perfectly on all browsers except for IE and Google Chrome when opened inside an iframe. Strangely, it still functions flawlessly in Firefox. How can I resolve this frustrating issue? The image link was sourced from the i ...

Tips for executing an npm command within a C# class library

I am currently developing a project in a class library. The main objective of this project is to execute a JavaScript project using an npm command through a method call in C#. The npm command to run the JavaScript project is: npm start The JavaScript ...

Automatically format text fields to display time in hh:mm format from right to left as you type

Is there a way to automatically format hh:mm as the user types in a text field? The default format is 00:00, and I would like it to fill the minutes part when the first two characters are entered, followed by filling the hour part with the third and four ...

The decision will be dependent on the outcomes provided by the $resource promise

I have been working on calling my API with AngularJS to retrieve a list of 'reports' and then displaying them in a modal or saving the sale depending on whether any results were returned. I've been struggling with this for a while and would ...

Strange alignment issues occurring solely on certain PCs

Currently, I am in the process of developing a website for a client who has requested that it be an exact replica of the mockup provided. However, I have encountered some issues with the headers and certain divs that contain background elements. Surprising ...

Steer clear of using temporary tables for copying data

When I work in Java, I usually don't encounter issues like the one I'm facing here where it needs to copy to a table and then crashes. SELECT company.tblusers.userid, db.operations.id AS operation_id, SUM(TIME_TO_SEC(db.batch_log.time_elapsed)) ...

I'm feeling a bit lost trying to figure out how to write insert statements using knex

I'm struggling with a specific issue related to the Knex.JS implementation that I just can't seem to figure out. It's not directly related to PostgreSQL, but more about how Knex is handling my data. The code snippet below works fine for ins ...

Inconsistencies in grunt-ng-constant target operations

I encountered a strange issue with grunt-ng-constant where only 2 out of the 3 targets are working. Here is how my configuration is set up: grunt.initConfig({ ngconstant: { options: { space: ' ', wrap: '"use strict";&bso ...

I am having trouble executing a script as the steps I have followed are not yielding the desired results. I am wondering where I may have made a mistake

I am trying to execute a script provided by Maciej Caputa in response to this question: How to import CSV or JSON to firebase cloud firestore The objective is to utilize a JSON file for uploading data to Cloud Firestore. As a newcomer to running scripts, ...

How can we easily reset the min and max variables when the ID sequence is disrupted in Mariadb?

I have a set of identifiers with missing sequence gaps, and I need to determine the minimum and maximum sequence for use in another application. MariaDB [test]> select * from book_lists; +----+-----------+ | id | name | +----+-----------+ | 1 | c+ ...

Utilizing the Power of GrapesJs in Vue3

Recently, I attempted to integrate the GrapesJS editor into my Vue.js project, but encountered some difficulties. The editor was not visible in the browser, and the designated tag for the editor appeared empty. Here is my editor configuration: <template ...

Exploring the vertices of a single face of a cube using three.js

My current project involves manipulating the x position of all coordinates on a single face of a cube. Here is my current method: var wDepth = 200; var hDepth = 200; var geo = new THREE.CubeGeometry( 20, 40, 40, 20, wDepth, hDepth); for ( var i = ...

Tips for updating checked checkboxes in a php mysql database

When submitting an HTML form with a selected checkbox, update the values of the selected checkboxes in a MySQL database. For example: update enquires set status = '2' where id in (selected checkbox values) View the screenshot of the checkbox Vi ...

Retrieve the IDs of all currently logged in users using express.js

Currently, I am working on a project and need to extract a list of user ids of all currently logged in users. I came across a relevant question on StackOverflow at this link. However, I am facing difficulties in accessing the object properties as intended. ...

Utilizing the Angular *ngFor directive to iterate through JSON data

Just stepping into the world of Angular, I want to share a brief overview of my goal since the code is lengthy. Here's the relevant part: Within my project, I have a list display component. And I have two components, namely animals and zone. For in ...

Determining if data from two separate lists in Vue.js matches in order to display in the template

I need to compare two sets of data - one fetched from the server and the other being default data. Data retrieved from the server: [ { "id": 7, "day": "14 April 2017", "time_list": [ { "id": 25, "time": "11:00 AM", ...

Create an HTML container surrounding the content within the parent tags

I'm looking to create a wrapper that acts as the immediate parent of any HTML markup added within a shared class. This will eliminate the need to manually add multiple wrapper divs and allow for the customization of layouts and backgrounds. Essential ...