Skip to content
Advertisement

Ambiguous column using JDBC but query works fine in database

I am connecting to a SQLite database through java using JDBC.

Schema:

This query below runs fine in my database, but when I try it with JDBC:

Output:

If using person.id: no such column: 'person.id'

Without specifying: ambiguous column name 'id'

I’ve tried using both WorkInfo and Person and using aliases but it keeps throwing the same ambigious column name (if left as id) or column does not exist.

Advertisement

Answer

It’s always a good practice to explicitly retrieve the columns you want. I would change the query to be:

In this case, you can use the column index instead of the label.

Or using the AS clause:

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