查询:
select a.cName
from table1 a LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 ON a.code=b.code===这三个表的连接关系是怎么样的?
table1左连接table2
是table1连接table3还是table2连接table3
现在想table1同时连接table3怎么做?
select a.cName
from table1 a LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 ON a.code=b.code===这三个表的连接关系是怎么样的?
table1左连接table2
是table1连接table3还是table2连接table3
现在想table1同时连接table3怎么做?
解决方案 »
- 关于账户权限设置问题
- 【感谢】果果进来~!刚刚回答的那个问题
- 无法绑定由多个部分组成的标识符,太菜,很简单的将一个表的列值汇总到另一个表。
- 两个表互相更新的问题
- mssql查询分析器执行导入dbf失败
- mssql2000 如何查看谁远程连接过本机
- 向Haiwer请教,重复行需要显示在一起。
- 存储过程中Cursor的一个问题?
- [SQL-DMO]服务控制错误: RPC 服务器不可用
- 如何在程序中获知SQL SERVER数据库中有新的记录?高手请帮忙看看
- 如何将一个数据库的数据插入到另外一个数据库中的表中
- winxp上装了sql server2000个人版,telnet ip 1433竟然不通,打上sp4补丁才通,这正常吗?
table1左连接table3
select a.cName
from table1 a
LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code
from table1 a LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code
table1左连接table2,又左连接table3
from table1 a LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code
怎么试验得出来,这个语句和select cName from table1有什么区别?
--------------
这句代码有问题。
select a.cName
from table1 a LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code
FROM ((table1 a LEFT JOIN table2 b ON a.code = b.code)
LEFT JOIN table3 c ON a.code = c.code)
这个问题看似很基础!
上楼的兄弟,这句问题出在哪里?
学习ing~~:)
from table1 a
LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code过程是这样的:
1, 首先table1左链接table2,得到一个中间结果,该中间结果包括table1的所有行以及table2中与table1匹配条件(a.code=b.code)的行
2, 该中间结果左链接table3,得到最终的行集,该行集中包括上一步的中间结果的所有行以及table3中与中间结果匹配条件(a.code=c.code)的行
上楼的兄弟,这句问题出在哪里?
-----------------------------
你要连接的是 table3
但是连接条件中写的却是 a和b,也就是table1和table3,没有table3是不行了。
所以给table3起个别名,然后在连接条件中指定条件。
from table1 a
LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code
查询结果和select cName from table1 有区别吗?
-------------------
我想楼主是举例,实际上并不会是这种连接条件。
-------------------
我想楼主是举例,实际上并不会是这种连接条件。-----------------------------
有区别的,当code在表2不唯一的时候,返回结果是多条
from table1 a
LEFT JOIN table2 b ON a.code=b.code
LEFT JOIN table3 c ON a.code=c.code
对的