分享到:
发表于 2009-01-22 10:37:47 楼主 | |
两个表:mysql> select * from a1; +------+---------+-------+ | id | subject | score | +------+---------+-------+ | 1 | shux | 80 | | 2 | yuwe | 60 | | 3 | engl | 70 | +------+---------+-------+ 3 rows in set (0.00 sec)mysql> select * from b1; +------+----------+ | id | name | +------+----------+ | 1 | zhangsan | | 2 | lisi | | 4 | wangwu | +------+----------+ 3 rows in set (0.00 sec)左连接,右连接均正常。mysql> select a1.*,b1.* from a1 left outer join b1 on a1.id=b1.id; +------+---------+-------+------+----------+ | id | subject | score | id | name | +------+---------+-------+------+----------+ | 1 | shux | 80 | 1 | zhangsan | | 2 | yuwe | 60 | 2 | lisi | | 3 | engl | 70 | NULL | NULL | +------+---------+-------+------+----------+ 3 rows in set (0.02 sec)mysql> select a1.*,b1.* from a1 right outer join b1 on a1.id=b1.id; +------+---------+-------+------+----------+ | id | subject | score | id | name | +------+---------+-------+------+----------+ | 1 | shux | 80 | 1 | zhangsan | | 2 | yuwe | 60 | 2 | lisi | | NULL | NULL | NULL | 4 | wangwu | +------+---------+-------+------+----------+ 3 rows in set (0.00 sec) 全连接时,挂了,不知道为什么?? mysql> select a1.*,b1.* from a1 full outer join b1 on a1.id=b1.id; 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 'outer join b1 on a1.id=b1.id' at line 1 mysql> mysql> mysql> mysql> select a1.*,b1.* from a1 full join b1 on a1.id=b1.id; ERROR 1051 (42S02): Unknown table 'a1' mysql> 请大家帮忙看看。谢谢! |
|
楼主热贴 |
发表于 2009-01-22 10:37:47 1楼 | |
难道说mysql不支持??? |
|
发表于 2009-01-22 10:37:47 2楼 | |
5.1支持 MYSQL 中 的FULL JOIN 可以用LEFT JOIN UNION RIGHT JOIN 来模拟。 |
|
针对ZOL星空(中国)您有任何使用问题和建议 您可以 联系星空(中国)管理员 、 查看帮助 或 给我提意见