I'm trying to join two tables in sqlite with an alias on one of the columns, but when I alias the column, it returns null.
I've got two tables, like this:
sqlite> SELECT * FROM series;
_id = 1
name = Castle
type = show
who = dan
disabled = 0
sqlite> SELECT * FROM series_meta;
meta_id = 1
series_id = 1
meta_name = year
meta_type = int
meta_text =
meta_int = 2009
Now, I try the following query: SELECT _id, name, type, who, disabled, y.meta_int AS year FROM series LEFT JOIN series_meta AS y ON _id=y.series_id AND y.meta_name="year"; I get:
_id = 1
name = Castle
type = show
who = dan
disabled = 0
year =
But if I get rid of the column alias (SELECT _id, name, type, who, disabled, y.meta_int FROM series LEFT JOIN series_meta AS y ON _id=y.series_id AND y.meta_name="year";), I get the expected result:
_id = 1
name = Castle
type = show
who = dan
disabled = 0
meta_int = 2009
I've tried this with sqlite 3.8.8.2 on Windows 7. I also tried it using python, with the exact same results. Removing the table alias doesn't change anything either.
Is there no way to get this to work with a column alias?
Aucun commentaire:
Enregistrer un commentaire