'Unknown column 'reported_bugs' in 'where clause' when selecting reported_bugs from bugLoc - MySQL

MySQL is throwing Unknown column 'reported_bugs' in 'where clause' whenever I try selecting all the rows that have reported_bugs as their bugLoc. I'm not sure what's going wrong, because I'm not trying to select a column named reported_bugs.

Here's the line it throws the error on: reported_bugs = cursor.execute(f"SELECT bugDesc FROM {username}Bugs WHERE bugLoc = reported_bugs")

I need it to find all rows that have "bugLoc" as "reported_bugs," and get the bugDesc from those rows. Any help would be greatly appreciated!



Solution 1:[1]

if you don't add quotes reported_bugs is interpreted like a name. Instead you were looking for the string value, so you must write

reported_bugs = cursor.execute(f"SELECT bugDesc FROM {username}Bugs WHERE bugLoc = 'reported_bugs'")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrea_86