[SOLVED] Unknown column 'reported_bugs' in 'where clause' when selecting reported_bugs from bugLoc – MySQL

Issue

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

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'")

Answered By – Andrea_86

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.