On Wed, 12 Mar 2008 12:53:33 -0600 (MDT), you wrote:

>I have noticed what appears to be an inconsistency of returned field
>names. 
>
>Two queries accessing the same field in the same table are returning
>slightly different field names. I don't know if this is by design or by
>accident and I'm simply reporting what I see.
>
>________________________________________________________________
>
>QUERY1:
>-------
>"SELECT [categoryIndex] FROM CategoriesContent WHERE [contentIndex] = %i
>ORDER BY [categoryIndex] ASC;";
>
>--> returns a field name of "categoryIndex".
>
>________________________________________________________________
>
>QUERY2:
>-------
>"SELECT DISTINCT [categoryIndex] FROM CategoriesContent WHERE [new] = 1
>ORDER BY [categoryIndex] ASC;";
>
>--> returns a field name of "[categoryIndex]".
>
>________________________________________________________________
>
>I am using SQLite3 version 3.5.4.
>
>Lee Crain

Either don't use [] around column names or add an
alias to explicitly name the resultcolumn:

SELECT DISTINCT categoryIndex
  FROM CategoriesContent
 WHERE new = 1
 ORDER BY categoryIndex ASC;

SELECT DISTINCT [categoryIndex] AS catindex
  FROM CategoriesContent 
 WHERE [new] = 1
 ORDER BY [categoryIndex] ASC;

I agree it seems slightly inconsistent behaviour.
[] around identifiers are not standard SQL. 
You would only need them (or double quotes, which is
standard SQL) if you choose reserved words as
identifiers.
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to