[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] Correct SQL name resolution on AS clauses in a SELECT?
From:       Chris Wedgwood <cw () f00f ! org>
Date:       2008-08-19 22:09:14
Message-ID: 20080819220914.GA24746 () puku ! stupidest ! org
[Download RAW message or body]

MySQL:

mysql>      SELECT a AS b, b AS a FROM t1 ORDER BY a;
+------+------+
> b    | a    |
+------+------+
> 1 |    2 |
> 9 |    8 |
+------+------+
2 rows in set (0.00 sec)

mysql>      SELECT b AS a, a AS b FROM t1 ORDER BY a;
+------+------+
> a    | b    |
+------+------+
> 2 |    1 |
> 8 |    9 |
+------+------+
2 rows in set (0.00 sec)

mysql>      SELECT a, b AS a FROM t1 ORDER BY a;
ERROR 1052 (23000): Column 'a' in order clause is ambiguous

mysql>      SELECT a AS x, b AS x ORDER BY x;
ERROR 1054 (42S22): Unknown column 'a' in 'field list'


mysql>      SELECT a AS b, b AS a WHERE a=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that \
corresponds to your MySQL server version for the right syntax to use near 'WHERE a=1' \
at line 1

mysql>      SELECT a AS b, b AS a WHERE a=2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that \
corresponds to your MySQL server version for the right syntax to use near 'WHERE a=2' \
at line 1

mysql>      SELECT a AS x, b AS x WHERE x=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that \
corresponds to your MySQL server version for the right syntax to use near 'WHERE x=1' \
at line 1 _______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic