Skip to content
Advertisement

Using Python, how to return just one value instead of an entire row in an SQL query

I have a SQL database file which contains a multitude of columns, two of which are ‘GEO_ID’ and ‘MED_INCOME’. I am trying to retrieve just the ‘MED_INCOME’ column data using the associated ‘GEO_ID’. Here is what I thought would work:

Which results in:

I thought that I had used this method before when attempting to retrieve the data from just one column, but this method does not appear to work. If I were to instead write:

I get the full row’s data, so I know the ID is in the database file.

Is there something about my syntax that is causing this request to result in an empty set?

Advertisement

Answer

Per @Ernxst comment, I adjusted the request to:

Removing the quotes around the column ID, which solved the problem.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement