There are 3 tables student, course, and takes as following tot_cred column data in the student table now is assigned with random values (not correct), I want to perform the query that updates and renews those data based on the course’s grade each student has taken. For those students who received F grad…
Tag: database
aiosqlite “Result” object has no attribue “execute”
I’m making a discord.py bot and I’m currently on the economy part, but I’m encountering a strange error that I’ve never ran into before and has most of the python discord help dumbfounded. The error is as follows: Command raised an exception: AttributeError: ‘Result’ has no…
Why am I unable to select all records in one table that don’t exist in another table?
I have two tables like: Desired output: I want to select all records in col1 of table_1 that aren’t in col1 of table_2. In actuality, table_1 has 65000+ rows and table_2 has around 2000 rows. My query: This returns no records. However, the reverse works as intended when I select all records in table_2 t…
SQL how do I sum up a has many relationship
So I have the following table, I managed to join users and membership tables just fine with a left join however I’ve been unsuccessful at summing up the individual customers’ total. Here’s my code, the one-to-one associations seem to be doing fine however the summing up of the total seems to…
SQL to fetch value of one column such that a certain value in another column does not exist
I have the following Table t key value 1 a 1 b 1 c 2 a 2 c In the above table, the Key 1 has three values i.e. a, b and c. However Key 2 has only two values i.e. a and c. How to write a SQL that would return the Key that does NOT have the value
MySql query to return a random row returns unexpected number of rows
I am trying to get a random word from a long list of words in a MySql table: word_list [id*|wword]. My query looks at the moment like this: SELECT * FROM word_list w where id = (SELECT FLOOR(1 + RAND()*(10-1))) I thought the above query would return one and only one random row with Id between 1 and 9. To
How to fix cache lookup failure/corrupted database?
I’ve got a postgres database that I’m trying to clean up with drop schema public cascade. The data on it is not that important and I never made any backups. I’m just trying to rebuild it. However, it seems an error I made earlier is causing the drop command to fail. When I run drop schema pu…
To find passengers travelling more than thrice on the same route in PL/SQL
Here I am creating three tables, one for storing the Train Info. Another for holding onto the Passenger info and the other one to hold the ticket Info. In the Train_Info table, I am inserting two unique routes with the same source and destination as there can be different routes for the same source and destin…
Display SQL query result on front-end WordPress site
I am trying to get the total data (SUM) within a column in a WordPress database. I am using the following SQL (and PHP) code to run the request; however, I do not know how to display the result on the front end of my site. or I have tried using print_r($avg_items_purchased); and var_dump($avg_items_purchased)…
How to keep table name when inner joining related tables
I am new to SQL and wonder how to select nested tables. I have two tables like this: sensors sensor_id model_no location_id int varchar int locations location_id name location radius int varchar point int They are linked with foreign key. Currently, I select using to get the data from both like this: I wonder…