0

Here is the error SQL statement:

RuntimeError: (sqlite3.OperationalError) near ",": syntax error [SQL: "SELECT stock, SUM(shares) AS shares FROM 'transaction' WHERE userid = 3, stock = 'FB'"]

I'm trying to check if user has enough shares in his portfolio. So need to query the total shares for the specific stock. But I constantly get error on this statement. Is there a way to do this using SQL statement? Or should I query the shares out and sum it out of SQL statement... I have a similar SQL statement for buy() which works fine:

    rows = db.execute("SELECT stock, SUM(shares) AS shares FROM 'transaction' WHERE userid=:user_id GROUP BY stock", user_id=session["user_id"])
0

It's complaining about the , here: WHERE userid = 3, stock = 'FB'

WHERE clauses in sqlite are evaluated as boolean expressions. So the proper syntax would be WHERE userid = 3 and stock = 'FB'.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .