Geeks Talk

Prepare for your Next Interview




Can Select statement be used along with Update statement?

This is a discussion on Can Select statement be used along with Update statement? within the SQL forums, part of the Databases category; Can Select statement be used along with Update statement in an SQL Query?...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-23-2007
Junior Member
 
Join Date: Aug 2007
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
pankit is on a distinguished road
Can Select statement be used along with Update statement?

Can Select statement be used along with Update statement in an SQL Query?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-23-2007
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,330
Thanks: 7
Thanked 117 Times in 106 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: Can Select statement be used along with Update statement?

Yes that can be used ,
You can update one field by selecting from another field / table.
Reply With Quote
  #3 (permalink)  
Old 01-10-2008
Junior Member
 
Join Date: Dec 2007
Location: india
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
nitin_padwal is on a distinguished road
Re: Can Select statement be used along with Update statement?

following query will help you to update multiple columns at once

update tblOuter
set colOuter1 = a.colInner1,
colOuter2 = a.colInner2,
colOuter3 = a.colInner3,
from ( select colInner1,colInner2,colInner3
from tblInner
where conditions on tblInner columns
) as a
where condition on tblOuter's columns

be careful with your where conditions..........
Reply With Quote
The Following User Says Thank You to nitin_padwal For This Useful Post:
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Is this a correct statement anoop4real C and C++ 13 05-22-2008 06:22 AM
Why we have to close connection, statement, prepared statement Geek_Guest Java 8 02-27-2008 06:09 AM
I just want to commit my second Insert statement Geek_Guest Oracle 1 07-21-2007 05:48 AM
How many Case statments can i use in Switch Statement Geek_Guest C and C++ 9 07-03-2007 04:56 AM
Rules for COPY statement norman MainFrame 1 08-14-2006 04:11 AM


All times are GMT -4. The time now is 09:18 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved