sql问题,oralc和sql server [英] sql issue, oralc and sql server
问题描述
大家好,我有一个sql的问题,就是当我们使用select时,我认为总有2种方法,
选择
name.t1,name.t2,name.t3
来自
t1,t2,t3
其中
t1.id = t2.id 和 t2.id = t3.id
或
选择
name.t1,name.t2,name.t3
from
t1
内部 join t2 on t1.id = t2.id
内部 加入 t3 t2.id = t3.id
所以,
1.它们之间的区别是什么2种方法选择?
2.如果我们使用第一种方法, oracle,我们可以用(+)来实现左边或右边的连接,但是在sql server或mysql或者mb等数据库中,如何使用1st方法实现左连接?
提前感谢!
这里有一些错误的语法。它应该像table.Coluumn not column.table
选择
t1.name,t2.name,t3.name
from
t1,t2,t3
其中
t1.id = t2.id 和 t2.id = t3.id
答1:第一个是短手(也是旧方法)所以这样做,而后来的一个是详细的方式,并且可读性很高。
答2:
选择 t1.name,t2 .name,t3.name
来自 t1
left 加入 t2 t1.id = t2.id
left join t3 t2.id = t3.id
在短手中使用左外连接de,尝试使用*符号。
例如其中a.col1 * = b.col1
hi guys, i have a issue with sql, that is when we use "select", i think there're always 2 methods ,
select
name.t1,name.t2,name.t3
from
t1,t2,t3
where
t1.id=t2.id and t2.id=t3.id
or
select
name.t1,name.t2, name.t3
from
t1
inner join t2 on t1.id=t2.id
inner join t3 on t2.id=t3.id
so,
1.what's the differences between the 2 methods of select ?
2.if we use the 1st method, in oracle, we can use(+) to achieve left or right join, but in sql server or mysql or mb other database, how can we achieve left join in using the 1st method?
thanks in advance!
You have some wrong syntax here. It should be like table.Coluumn not column.table
select t1.name,t2.name,t3.name from t1,t2,t3 where t1.id=t2.id and t2.id=t3.id
Ans1: The first one is short hand(also the old method) so doing this while later one is the detailed way and much readable.
Ans2:
select t1.name,t2.name,t3.name from t1 left join t2 on t1.id=t2.id left join t3 on t2.id=t3.id
To use left outer join in short hand mode, try using * symbol.
E.g.Where a.col1 *= b.col1
这篇关于sql问题,oralc和sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!