2015-07-09 19:15:07 2965次浏览 1条回答 0 悬赏 30 金钱
mysql> select* from table1;
+------+-------+
| id   | name  |
+------+-------+
|    1 | lee   |
|    2 | zhang |
|    4 | wang  |
+------+-------+
3 rows in set (0.00 sec)

mysql> select * from table2;
+------+-------+
| id   | score |
+------+-------+
|    1 |    90 |
|    2 |   100 |
|    3 |    70 |
+------+-------+
3 rows in set (0.00 sec)

mysql> select * from table1 full join table2 on table1.id=table2.id;
ERROR 1054 (42S22): Champ 'table1.id' inconnu dans on clause

我都怀疑是不是版本问题,或者full join on 用法 淘汰了呢

最佳答案

  • RichardTian 发布于 2015-07-09 19:28 举报
    SELECT table1.* FROM table1,table2 WHERE table1.id = table2.id;
    
    2 条回复
    回复于 2015-07-09 19:37 回复

    这个sql语句是对滴。 我想要研究的是join full 的用法。今天面试问了一堆sql join 方面的问题,所以想好好研究一下join的用法

    id name id score
    ------------------------------
    1 lee 1 90
    2 zhang 2 100
    4 wang NULL NULL
    NULL NULL 3 70
    ------------------------------
    

    这是我预计要的效果。。。

    回复于 2015-07-09 19:53 回复

    原因找到了, 是mysql 不支持 full join on的用法。 其他数据库基本上都支持这个用法

    觉得很赞
    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
样歌party
见习主管

样歌party

注册时间:2015-05-28
最后登录:2015-07-11
在线时长:5小时10分
  • 粉丝2
  • 金钱280
  • 威望0
  • 积分330

热门问题