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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updating price column based on another price colum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SergioM
Posting Yak Master

168 Posts

Posted - 08/13/2013 :  15:53:22  Show Profile  Reply with Quote
I'm so close, but I just don't have it. I received this good advice about updating one row, based on a different row's price (http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=187393)

My dataset looks like this:
ID	BuyDotComPrice	CompanyID	ShadowOf
AB CIRCLE PRO	199.99	203	
AB CIRCLE PRO-b2	199.99	203	AB CIRCLE PRO
AB CIRCLE PRO-TB	249.99	344	AB CIRCLE PRO
AB CIRCLE PRO-TB-S1	0	344	AB CIRCLE PRO


I need to update the price of an item where the CompanyID is 344 and the ShadowOf is not null. The value in ShadowOf is the same as the ID that I want to get the BuyDotComPrice for. It should be simple, but I keep getting errors.

-Sergio
I use Microsoft SQL 2008

Edited by - SergioM on 08/13/2013 15:53:41

James K
Flowing Fount of Yak Knowledge

3744 Posts

Posted - 08/13/2013 :  15:57:34  Show Profile  Reply with Quote
Post the query you currently have even if is not working right or giving you an error. From your description, it looks like you will need a where clause something like shown below.
....
WHERE
   CompanyID=344
   AND ShadowOf IS NOT NULL
However, that will update two rows in your example. If you want to update only one of those rows, you have to have some rule to determine which of those you want to update.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.03 seconds. Powered By: Snitz Forums 2000