mcfly soft
mcfly soft

Reputation: 11655

left Join old syntax migration

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

Upvotes: 0

Views: 1116

Answers (3)

Keren Caelen
Keren Caelen

Reputation: 1466

Both will be equivalent but

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

will be more acceptable.

Upvotes: 0

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239744

Your first guess is correct. This query:

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

and this query:

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

Produce the same results - provided that the original query was well-behaved with other predicates in the WHERE clause - the whole reason why the old syntax is deprecated is that it could produce "interesting" results in some cases - so if you were relying on those, you won't get them.

Upvotes: 3

Thangamani  Palanisamy
Thangamani Palanisamy

Reputation: 5300

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

This is Correct one

Upvotes: 1

Related Questions