Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
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?...
|
|||||||
|
|||
|
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.......... |
| The Following User Says Thank You to nitin_padwal For This Useful Post: | ||
|
|||
|
Re: Can Select statement be used along with Update statement?
yes you can use select statment in update
Example:- update employees set salary=10000 where employee_id=select employee_id from employees where last_name='king' and department_id=10; |
| The Following User Says Thank You to rajgupta7666 For This Useful Post: | ||
|
|||
|
Re: Can Select statement be used along with Update statement?
Yes you can...
Here some examples for u... 1) UPDATE Table1 SET Table1(col1) = (SELECT Table2(col1) FROM Table2 WHERE some condition); 2) UPDATE Table1 SET Table1(col1)='xxxxxxxxxx' WHERE Table1(col2)= ( SELECT ab.Table2(col2) FROM Table1 a, Table2 ab WHERE a.Table1(col3)=ab.Table2(col3) ); 3) UPDATE Table1 SET Table1(col1) = ( SELECT Table2.col1 FROM Table2 WHERE Table2.col2 = Table1.col2) WHERE EXISTS ( SELECT Table2.col1 FROM Table2 WHERE Table2.col2 = Table1.col2); |
![]() |
|
| 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 |