以下2条语句是加入使用gift.giftID = sentgifts.giftID:
mysql> select * from gifts, sentgifts using (giftID);
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 'using
(giftID)' at line 1
第二个:
mysql> select * from gifts INNER JOIN sentgifts using (giftID);
+--------+------------+----------------+---------------------+--------+------------+--------+------+---------------------+
| giftID | name | filename | effectiveTime | sentID | whenSent | fromID | toID | trytryWhen |
+--------+------------+----------------+---------------------+--------+------------+--------+------+---------------------+
| 2 | teddy bear | bear.jpg | 2010-04-24 04:36:03 | 4 | 2010-04-24 | NULL | 111 | 2010-04-24 03:10:42 |
| 6 | beer | beer_glass.png | 2010-04-24 05:18:12 | 5 | 2010-03-03 | 11 | 22 | 2010-03-03 00:00:00 |
| 6 | beer | beer_glass.png | 2010-04-24 05:18:12 | 6 | 2010-04-24 | 11 | 222 | 2010-04-24 03:54:49 |
| 6 | beer | beer_glass.png | 2010-04-24 05:18:12 | 7 | 2010-04-24 | 1 | 2 | 2010-04-24 03:58:45 |
+--------+------------+----------------+---------------------+--------+------------+--------+------+---------------------+
4 rows in set (0.00 sec)
第一条语句也可以使用“使用”速记吗?似乎在使用时必须指定“Inner Join”这个词......但第一个语句实际上是一个内连接?
更新:如果不能完成,有什么原因吗?第一条声明实际上已经足够清楚了要做什么......有禁止它的理由吗?