Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 What is the difference?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Namagiri
Starting Member

5 Posts

Posted - 03/25/2013 :  12:21:59  Show Profile  Reply with Quote
UPDATE OD
SET discount += 0.05
FROM dbo.OrderDetails AS OD
JOIN dbo.Orders AS O
ON OD.orderid= O.orderid
WHERE O.custid= 1;


UPDATE OD
SET discount += 0.05
FROM dbo.OrderDetails AS OD
JOIN dbo.Orders AS O
ON OD.orderid= O.orderid
and O.custid= 1;



Thanks

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2179 Posts

Posted - 03/25/2013 :  12:41:53  Show Profile  Visit jackv's Homepage  Reply with Quote
They look similar , in terms of the resultset you'll see. Althougfh the syntax is different i.e WHERE versus = .

Jack Vamvas
--------------------
http://www.sqlserver-dba.com

Edited by - jackv on 03/26/2013 02:50:45
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 03/25/2013 :  13:09:38  Show Profile  Reply with Quote
In the first query, you are using a WHERE clause to apply the predicate "O.custid= 1." Where as, with the second query, you are applying the predicate on the join clause. For an INNER JOIN there isn't a difference in the result set. However, if you do an OUTER join, where you apply the predicate can make a difference in the result set.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2242 Posts

Posted - 03/26/2013 :  03:19:14  Show Profile  Reply with Quote
Check these links for getting knowledge on LEFT JOIN with WHERE clause....

http://www.codeproject.com/Articles/231132/Difference-between-And-clause-along-with-on-and-Wh
http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/
Go to Top of Page

Namagiri
Starting Member

5 Posts

Posted - 03/26/2013 :  15:28:57  Show Profile  Reply with Quote
Thanks everyone. Thanks bandi for the links.

Edited by - Namagiri on 03/26/2013 15:29:13
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2242 Posts

Posted - 03/27/2013 :  01:16:14  Show Profile  Reply with Quote
quote:
Originally posted by Namagiri

Thanks everyone. Thanks bandi for the links.


Welcome

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000