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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 filter based update
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

magmo
Aged Yak Warrior

509 Posts

Posted - 02/07/2013 :  06:51:56  Show Profile  Reply with Quote
Hi

I need to filter based on this query result...


SELECT        dbo.tbl_OrderInfo.IsFetched
FROM            dbo.tbl_Customer INNER JOIN
                         dbo.tbl_Login ON dbo.tbl_Customer.CustID = dbo.tbl_Login.CustID INNER JOIN
                         dbo.tbl_OrderInfo ON dbo.tbl_Login.UID = dbo.tbl_OrderInfo.UserUniqueID
WHERE        (dbo.tbl_Customer.CustID = 89) AND (dbo.tbl_OrderInfo.IsFetched = 0) OR
                         (dbo.tbl_OrderInfo.IsFetched IS NULL)




I need to update all dbo.tbl_OrderInfo.IsFetched and set them to dbo.tbl_OrderInfo.IsFetched = 1, how do change the code above?

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/07/2013 :  06:59:14  Show Profile  Reply with Quote

UPDATE dbo.tbl_OrderInfo
SET dbo.tbl_OrderInfo.IsFetched = 1
FROM            dbo.tbl_Customer INNER JOIN
                         dbo.tbl_Login ON dbo.tbl_Customer.CustID = dbo.tbl_Login.CustID INNER JOIN
                         dbo.tbl_OrderInfo ON dbo.tbl_Login.UID = dbo.tbl_OrderInfo.UserUniqueID
WHERE        (dbo.tbl_Customer.CustID = 89) AND (dbo.tbl_OrderInfo.IsFetched = 0) OR
                         (dbo.tbl_OrderInfo.IsFetched IS NULL)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3587 Posts

Posted - 02/07/2013 :  07:01:05  Show Profile  Reply with Quote
"I need to update all dbo.tbl_OrderInfo.IsFetched" <-- You mean all that are returned via the select query? If so:
--SELECT dbo.tbl_OrderInfo.IsFetched
UPDATE dbo.tbl_OrderInfo SET
	IsFetched = 1
FROM   dbo.tbl_Customer
       INNER JOIN dbo.tbl_Login
            ON  dbo.tbl_Customer.CustID = dbo.tbl_Login.CustID
       INNER JOIN dbo.tbl_OrderInfo
            ON  dbo.tbl_Login.UID = dbo.tbl_OrderInfo.UserUniqueID
WHERE  (dbo.tbl_Customer.CustID = 89)
       AND (dbo.tbl_OrderInfo.IsFetched = 0)
       OR  (dbo.tbl_OrderInfo.IsFetched IS NULL)
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.05 seconds. Powered By: Snitz Forums 2000