mardi 31 mars 2015

Getting the table name as a column prefix in SQLite

I'm trying to run the following query:



SELECT artist_trackings.status, artists.* FROM artists LEFT OUTER JOIN artist_trackings ON artists.id = artist_trackings.artist_id WHERE id = 510 AND tracker_id = 7294574


The cursor I am returned contains all the correct columns, however their names are things like "id", "name", etc instead of "artists.id" and "artists.name". Also, "artist_trackings.status" is just returned as "status".


One solution I know is to go through the projection and do something like:



SELECT artist_trackings.status AS artist_trackings_status....


And so on, but for very big tables I have this is a total pain and shouldn't be necessary I'd think.


How do I force queries to always return the table name as a prefix to the columns on join queries like this? Shouldn't that happen automatically?


Aucun commentaire:

Enregistrer un commentaire