> On 31 Oct 2014, at 12:30pm, Jose F. Gimenez <jfgime...@wanadoo.es> wrote:
> 
> SELECT a, b, table2.c, alias.c
> FROM table1
> LEFT JOIN table2 ON ...
> LEFT JOIN table2 AS alias ON ...
> 
> the API sqlite_column_table_name() applied to both columns 3 and 4 returns 
> <table2>. I know that <c> belongs to <table2> in both cases, but is there any 
> way to get <table2> for column 3 and <alias> for column 4?

Specify which names you want SQLite to use:

SELECT a, b, table2.c AS table2, alias.c AS alias
FROM table1
LEFT JOIN table2 ON ...
LEFT JOIN table2 AS alias ON ...

However, I strongly advise against having one string which is both a table name 
and a column name ("table2" in your example).  I cannot right now think of a 
problem this will trigger but I suspect you're just setting yourself up for 
later confusion.  Perhaps use something like <table2_c>.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to