0

I have to migrate an old SQL Statement to SQLServer2008. The old SQL-Statement still has the old Join-Operator "*=". Of course I could set the DB-Compatibility, but I don't like to do this :-)

My Question: I am not sure if I am doing following correct and I can't test the old statement anymore. Could someone please check the syntax of my new SQL-Statement ?

old original statement :

select * from A,B where A.field *= B.field

My guess:

SELECT * from A
LEFT JOIN B
ON A.field=B.field;

Or is it the opposit way ? :

SELECT * from B
LEFT JOIN A
ON B.field=A.field;

Thanks and regards

4

3 回答 3

3

你的第一个猜测是正确的。这个查询:

select * from A,B where A.field *= B.field

这个查询:

SELECT * from A
LEFT JOIN B
ON A.field=B.field;

产生相同的结果——前提是原始查询与子句中的其他谓词表现良好WHERE——旧语法被弃用的全部原因是它在某些情况下会产生“有趣”的结果——所以如果你依赖那些,你不会得到它们。

于 2013-06-07T10:26:16.623 回答
1
SELECT * from A
LEFT JOIN B
ON A.field=B.field;

这是正确的

于 2013-06-07T10:25:55.463 回答
0

两者都是等价的,但是

SELECT * from A
LEFT JOIN B
ON A.field=B.field;

会更容易接受。

于 2013-06-07T10:10:03.733 回答