On 1 Nov 2014, at 12:29pm, Jose F. Gimenez <jfgime...@wanadoo.es> wrote:

> But if I need the column's fullname, I get:
> 
> messages.subject, people.name, people.name
> 
> And yes, I know that I can specify an alias for those columns which could be 
> ambiguous. That is "sender.name AS sender_name" and "receipt.name as 
> receipt_name", but what about a query like "SELECT messages.*, sender.*, 
> receipt.* ..." which will be processed later by a reporting system that knows 
> nothing about original columns? In this case, it's absolutely needed to 
> distingish between <sender.name> and <receipt.name>, <sender.departament> and 
> <receipt.departament>, and so on.

This is from the documentation of SQLite:

<https://www.sqlite.org/c3ref/column_name.html>

"The name of a result column is the value of the "AS" clause for that column, 
if there is an AS clause. If there is no AS clause then the name of the column 
is unspecified and may change from one release of SQLite to the next."

If you do not use AS, then you have no idea what the names of your columns are. 
 You cannot even rely on each column having a different name.  You might 
upgrade to a slightly higher version of SQLite because of a bug, and get 
completely different names for the columns in your result.

If you want to have any idea about your column names at all, assign each one 
using an "AS" clause.

If you want to pass the results of "SELECT * FROM ..." to something else and 
don't know the names of your columns, don't do a "SELECT * FROM ..." in the 
first place.  Use

<http://www.sqlite.org/pragma.html#pragma_table_info>

to find the names of the columns which exist, and create your SELECT from that.

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

Reply via email to