+ -
当前位置:首页 → 问答吧 → sql server2005左关联问题

sql server2005左关联问题

时间:2011-12-06

来源:互联网

select * from 
(
select 'a'a 
union all
select 'b'a 
)t1 ,
(
select 'a' aa 
)t2

where t1.a *=t2.aa 
提示错误:
此查询使用的不是 ANSI 外部联接运算符("*=" 或 "=*")。若要不进行修改即运行此查询,请使用存储过程 sp_dbcmptlevel 将当前数据库的兼容级别设置为 80 或更低。极力建议使用 ANSI 外部联接运算符(LEFT OUTER JOIN、RIGHT OUTER JOIN)重写此查询。在将来的 SQL Server 版本中,即使在向后兼容模式下,也不支持非 ANSI 联接运算符。

作者: hong1987   发布时间: 2011-12-06

2005越2000的不兼容
select * from  
(
select 'a'a  
union all
select 'b'a  
)t1 left Outer JOin
(
select 'a' aa  
)t2

On t1.a =t2.aa  

作者: mustudent   发布时间: 2011-12-06

SQL code

2005已经取消了*==*
用Left Outer Join与Right Outer JOin代替了

select * from   
(
select 'a'a   
union all
select 'b'a   
)t1 left Outer Join
(
select 'a' aa   
)t2
On t1.a =t2.aa  

作者: mustudent   发布时间: 2011-12-06

SQL code
select * from  
(
select 'a'a  
union all
select 'b'a  
)t1 ,
(
select 'a' aa  
)t2

where t1.a *=t2.aa --把*= 改成=

作者: maco_wang   发布时间: 2011-12-06

写成left join不就得了

作者: sjcss   发布时间: 2011-12-06

SQL code
select * from   
(
select 'a'a   
union all
select 'b'a   
)t1 left Outer Join--left join
(
select 'a' aa   
)t2

On t1.a =t2.aa   

作者: kingtiy   发布时间: 2011-12-06

那个是老古董了。

作者: fredrickhu   发布时间: 2011-12-06

SQL code

select * from  
(
select 'a'a  
union all
select 'b'a  
)t1 left join 
(
select 'a' aa  
)t2
on t1.a=t2.aa
/*
a    aa
---- ----
a    a
b    NULL

(2 行受影响)

*/

作者: pengxuan   发布时间: 2011-12-06

*= 兼容性很差

作者: yujianing1   发布时间: 2011-12-06