Questions tagged [sql]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 views

Check if added value corresponds to value/id from another table - SQL Final Project

I'm working on SQL Final project and I decided to create a database for a gym franchise. How can I make sure that a client can join classes only to which they have a card for (correct access level and ...
phnlg's user avatar
  • 1
0 votes
0 answers
44 views

parse error: no such table

I'm currently on week 1 of cs50's SQL course, running into some issues with the exercise. Running the code from both the file and the terminal results in a no such table, despite me already ...
Bryant Rusli's user avatar
0 votes
1 answer
100 views

CS50 Meteorites Cleaning

Quick Question for yall, so I set .nullvalue to "NULL" before writing my table updates. Second question, how do I rearrange columns in my final meteorites table that was it passes the CS50 ...
adubzzzz's user avatar
0 votes
1 answer
56 views

Finance pset, cs50's SQL INSERT statements results in runtime error

I'm trying to write a buy() function which would update user's stocks and his balance. I've added two new tables to my finance.db: stocks table for storing user's stocks and transactions table for ...
Nikolai Anisimov's user avatar
0 votes
0 answers
26 views

Question About Using SQL on Desktop Visual Studio Code

I am at week7 and I wanted to use SQL on my desktop Visual Studio code(which i successfully installed. I actually switch the Python version to 3.7.0 when running this, which removed the underline ...
king342's user avatar
0 votes
2 answers
225 views

CS50 SQL problem set 3 Meteorite Cleaning: NULL values are not present in "meteorites" table

Problem link: https://cs50.harvard.edu/sql/2023/psets/3/meteorites/ As the problem mentioned, any empty values in meteorites.csv are represented by NULL in the meteorites table. When I run the sqlite3 ...
yzrtt22's user avatar
0 votes
1 answer
37 views

cs50x Ps7 Movies 10.sql

On the Pset page it says that the solution must have 3392 rows. I wrote two different solutions, both accepted by check50, with different number of rows. The first one gives 3389 lines: SELECT ...
Nicolò Tiraboschi's user avatar
0 votes
0 answers
39 views

PSet7 Fiftyville: Two possible thieves and accomplices left, can't figure out how to narrow it down further

I've narrowed who the thief and accomplice are down to two choices, but I can't figure out how to narrow it down further (I already have where the thief escaped to). The only tables I haven't used are ...
They think im slow EH's user avatar
0 votes
1 answer
41 views

CS50 pset9: Why does 'SELECT last_insert_rowid()' return 0 instead of the expected value when using CS50 SQL library in Flask?

symbol_id = db.execute("SELECT symbol_id FROM symbols WHERE symbol = ?", quote["symbol"]) if not symbol_id: db.execute("INSERT INTO symbols (symbol) VALUES ...
khalildouis's user avatar
0 votes
0 answers
27 views

What's wrong with my 13.sql querry? PSET-Movies WEEK 7: SQL

I've been doing this Pset and I've completed all except for the last one. I was trying to figure out why. I think my result is ok because has the correct number of rows and Kevin Bacon doesn't appear ...
AlvaroAndLukeTheCoder's user avatar
0 votes
1 answer
44 views

SQL subqueries conditions ignored in Fiftyville Pset

I'm trying to call a select subquery where some conditions have to be met: SELECT * FROM people JOIN bakery_security_logs ON people.license_plate = bakery_security_logs.license_plate WHERE people....
Alex Sugimoto's user avatar
0 votes
0 answers
150 views

In PSET7 Movies, SQL.12 - issue with `and`

The below query doesn't work for reasons that are unclear to me. If I replace and with or, the query works, though not in the way specified by the problem. Why wouldn't and work in this case? -- write ...
chrisware's user avatar
0 votes
1 answer
360 views

ValueError: UNIQUE constraint failed: on finance pset9, could someone point me in the right direction on which values should be UNIQUE from my table?

Could someone help me figure out which values should I define as UNIQUE? I'm getting the ValueError: UNIQUE constraint failed: compras.id beacuase of the way I created my table for keeping tab of who ...
Roger Roger's user avatar
0 votes
1 answer
219 views

CS50 PSET7 Movies "query did not return results" 12.sql

First timer asking on Stack Exchange. I have a SQL query that returns 6 results in the terminal but does not work with check50 resulting in "Query did not return any results" I read in a ...
DavidLS7's user avatar
1 vote
1 answer
63 views

PSET7/SQL Any clues as to why my logic isn't working? (13.sql)

This very nested query is to return names of all the actors that performed on a Kevin Bacon film. Instead it's returning nothing, any ideas are appreciated! Note: I'm yet to implement the part that ...
General Noob's user avatar
0 votes
1 answer
303 views

SQL QUERY MOVIES.DB

I have written the query for 6.sql but it does not work. SELECT AVG(rating) FROM ratings WHERE movie_id = (SELECT id FROM movies WHERE year = 2012); I can do this by using JOIN SELECT AVG(rating) ...
MWD's user avatar
  • 86
0 votes
1 answer
766 views

Pset 7 Fiftyville

I am quite sure about my answers but check50 keeps saying its incorrect. Im not sure if I am giving the answers in the correct way. For ex. The thief escaped to Heathrow(I think)/ London but I am not ...
Dylan's user avatar
  • 7
0 votes
1 answer
582 views

PSET 9 Finance index.html issue with displaying table results with html

I'm currently on CS50 PSET 9 Finance and stuck on the index.html portion of the assignment. This is my code from assignment.py: @app.route("/") @login_required def index(): stocks = db....
Ryan Chua's user avatar
1 vote
1 answer
27 views

How do we delete existing flight in sqlite via Django?

In the notes for the SQLITE section, week 3, https://cs50.harvard.edu/web/2020/notes/4/#:~:text=delete%20your%20existing%20flight%20from%20New%20York%20to%20London It states: Every time we make ...
Katie Melosto's user avatar
0 votes
1 answer
218 views

Week 9 - I need a help about UNIQUE constraint

I am solving the week 9 problem using python. And I am interested in knowing how to deal with the error below using the if and elif? For example: rows = db.execute("SELECT username FROM users ...
Code Maker's user avatar
0 votes
0 answers
403 views

Sqlite3 ProgrammingError in Python (Flask, helper.py file)

I am currently working on my final project, a web application using flask, SQL and javascript. I came across this issue: `sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) Cannot operate on ...
Timi's user avatar
  • 1
0 votes
1 answer
694 views

pset7 Fifty Ville // not sure how to get the intersect of cases to find the thief

I am currently doing pset7 and I have found most of the clues of who it is but the problem is that I need to use the intersect sql function to find the common name of the thief but I am not sure how. ...
Arsham's user avatar
  • 27
0 votes
1 answer
423 views

CS50 SQL Library use outside of CS50 IDE

I am trying to create a SQlite database following Dr Malan's class example. The difference is that I am doing it outside of the CS50 IDE. For some reason the below code does actually create the .db ...
MJB's user avatar
  • 1
0 votes
1 answer
82 views

DIFFERENCE BETWEEN TWO SQL CODES

I wrote these two codes for SQL pset7 but I'm getting different answers. Can anybody tell me the cause of the difference? SELECT COUNT(title) FROM movies WHERE id = (SELECT movie_id FROM ratings WHERE ...
Olhuwhorlhey's user avatar
0 votes
1 answer
250 views

How to use a PostgreSQL database using python CS50 library's SQL function?

I wanted to use the CS50 library's SQL function for interacting with a PostgreSQL database. I have installed PostgreSQL on my computer and removed the need for passwords by modifying the .../Program ...
Huzaifa's user avatar
  • 101
0 votes
1 answer
377 views

CS50 finance SELL - Cannot get the code to subtract the stock from the database or index

I have tried a number of versions of this code, except I cannot get it to subtract shares from my ("/") index page it does nothing and shows nothing in the shares column in the transaction ...
Christopher White's user avatar
0 votes
1 answer
64 views

Project: Conditional style for html table

I have a table in html which gets the data from a SQL query in PY. One of the columns in my SQL table is type (tp). I want the html table to show one color for each row of the same type and another ...
Maria Macarena Garcia Michel's user avatar
0 votes
1 answer
75 views

pset 7 houses passes check 50 but shows the names 4 times

I have a really strange problem here: both import and rooster passes every check in check 50, but if I run Rooster the names on every house appear 4 times. I have no clue about why this is happening, ...
Alejandro Sánchez's user avatar
0 votes
1 answer
191 views

FINANCE: GROUP BY doesn't add up the numbers of shares of the same stock

So in index i'm trying to display a table with all the stocks that the user has bought, one row for each stock, displaying the total number of shares in the user's portfolio along with the total value ...
Ash's user avatar
  • 35
0 votes
1 answer
164 views

PSET8 Finance Buy. SQL query not executing

My buy function is crashing at the SQL query where I'm trying to insert data from the transaction into a transactions table. The types of each column are transaction_id(integer, primary key), user_id(...
Ewan Willsmer's user avatar
0 votes
1 answer
205 views

CASH NOT UPDATING - FINANCE SELL

so everything I have so far is working except the part where I need to update the cash right after I sell a stock. As you can see in the table below what's happening is that everytime I sell a stock ...
Bob's user avatar
  • 5
1 vote
1 answer
1k views

PSET 7 Movies SQL Q9

In 9.sql, write a SQL query to list the names of all people who starred in a movie released in 2004, ordered by birth year. ...Your query should output a table with a single column for the name of ...
Kevin Rodriguez's user avatar
0 votes
1 answer
189 views

Problem taking a SUM with SQL to python

I am doing Finance and I am fighting with this code... could anyone help me? I want to "select" some data from a sql table and put this value to a variable in python (a specific FLOAT number)...
santiago correa's user avatar
0 votes
1 answer
69 views

PSET 7 HOUSES - Syntax error on case function

I'm trying to select the first name and last name and ONLY select the middle name when there is one. The logic of my query makes sense. Every time I am extracting the first name, last name, and birth. ...
Bob's user avatar
  • 5
0 votes
1 answer
398 views

pset7 Q10 Weird Result

The challenge is apparently straightforward: write an SQL query to list the names of all people who have directed a movie that received a rating of at least 9.0. To get from names (which lives in the '...
RandomForestRanger's user avatar
0 votes
0 answers
29 views

Final Project: dynamic page creation to show just 10 SQL entries per page

I'm developing a web-page for my CS50's Final Project for contacting japanese students around Argentina. The only official japanese exam takes place in Buenos Aires, and there are no many good places ...
Lautaro D. Futuro's user avatar
0 votes
1 answer
205 views

Finance - Missing Value For Placeholder

As far as I can tell, I have the value set - username = username. Am I missing something stupid here? Code: @app.route("/register", methods=["GET", "POST"]) def ...
Brandon Zemel's user avatar
0 votes
1 answer
318 views

Pset7 (Movies) 12.sql: Table outputs 96 rows rather than 5 rows

I've been stuck on this for quite some time and did a lot of research on the AND operator in SQL, but no matter how many variations I try I cannot get my table to output just 6 rows, with each row ...
qwert9988's user avatar
0 votes
1 answer
262 views

PSET 7 - 6.sql, terminal just hangs

PSET 7 for 6.sql, Terminal just hangs when I execute it. Can anyone tell me why this wouldn't work? I've tried every variation I could think of (and several I found online) for this and none of them ...
Brandon Zemel's user avatar
0 votes
1 answer
183 views

Pset7 Movies Q12: I don't get what's wrong

I can't figure out why my pset7 movies Q12 code isn't working. Can anyone tell me why? Here is my code: SELECT DISTINCT title FROM movies, stars, people WHERE movie_id IN (SELECT movie_id FROM stars ...
Miguel's user avatar
  • 1
0 votes
1 answer
95 views

Can't import books.csv using import.py

I'm on a project1, here is the link to it: https://docs.cs50.net/ocw/web/projects/1/project1.html I've successfully made a Table books using my Python script, however when I try to import the "books....
Ayush Verma's user avatar
0 votes
1 answer
256 views

CHECK50 Bug in pset7: movies SQL

I have been banging my head on this for an hour and half. Finally finished the pset, uploaded it. Check 50 says: Now, both cs50 ide and DB browser return the correct results, and number of lines for ...
andrewdoeslearn's user avatar
1 vote
1 answer
291 views

Finance: Ensuring no duplicate usernames

I've implemented the following code in my "/register" route: def register(): """Register user""" if request.method == "GET": return render_template("register.html") else: #...
Jason C's user avatar
  • 13
0 votes
1 answer
384 views

PSET7 Movies Q8 - Why these queries return different results?

I'm working on pset7 movies problem of the CS50 course and I have a question regarding 8.sql, which asks to write a SQL query to list the names of all people who starred in Toy Story. To my ...
MADi's user avatar
  • 3
0 votes
1 answer
649 views

Pset 7 Movies - 13.sql "Error When Executing Query - Too Many Statements at Once"

I'm working on Pset 7 "Movies" and check50 shows an error for 13.sql (list of Kevin Bacon's co-stars) when I submit my code despite running successfully in the IDE. The exact error message is Error ...
kcoak1's user avatar
  • 3
0 votes
1 answer
83 views

Pset7 Houses, what does my error message mean?

Whenever I run my code, I get a strange error message because of my code. It is because of my SQL code, but I followed all of the instructions, and even tried some other SQL code, which worked ...
TC5001's user avatar
  • 2
0 votes
0 answers
117 views

Deleting SQL dynamically with Flask

I want to delete a specific row in my database but I don't know how to do it. On my HTML I have this: <div class="cases"> {% for row in rows %} <div class="card border-success mb-...
Ricardo Gusi's user avatar
0 votes
0 answers
2k views

(psycopg2.errors.UndefinedTable) relation "users" does not exist

when i try to load up regster.html i get this error "sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "users" does not exist LINE 1: INSERT INTO users(username,password) ...
beatmaister's user avatar
0 votes
1 answer
17 views

Difference between { var } vs :var as placeholder - SQL, Postgre

I was wondering if it's a good idea to use { var } in place of :var as placeholder? This is what I see in CS50 notes: flight = db.execute("SELECT * FROM flights WHERE id = :id", {"id": flight_id})....
TheOnlyAnil's user avatar
0 votes
0 answers
160 views

How to ensure proper database url in environment variable?

I am trying to run the code from lecture3 and I am having trouble ensuring the database url is properly set using the environment variable. Here's the code: db_url = 'postgresql+psycopg2://{username}:...
S. Miller's user avatar
  • 101