473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Update multiple columns

jamesd0142
469 256MB
Hi this is wiered but i can't think how to do it...

I have a fully populated table (call it table1) which looks:

col01 | col02 | col03 | col04 | col05 | col06 |.........

Now what i want is to add a column (call it col07) and populate this with a combiantion of col02+col03+col04.

so it looks like this:

col01 | col02 | col03 | col04 | col05 | col06 | col07
...1.........2..........3..........4.........5.... ....6......234...

(ignore the full stops they are for display purposes)

i tried this query:

Expand|Select|Wrap|Line Numbers
  1. update table1
  2. set col07 = (select col02+col03+col04 from table1)
  3.  
this obviously doesnt work.
Error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

so can any1 help...?

Cheers James
Dec 14 '07 #1
2 1160
amitpatel66
2,367 Expert 2GB
Hi this is wiered but i can't think how to do it...

I have a fully populated table (call it table1) which looks:

col01 | col02 | col03 | col04 | col05 | col06 |.........

Now what i want is to add a column (call it col07) and populate this with a combiantion of col02+col03+col04.

so it looks like this:

col01 | col02 | col03 | col04 | col05 | col06 | col07
...1.........2..........3..........4.........5.... ....6......234...

(ignore the full stops they are for display purposes)

i tried this query:

Expand|Select|Wrap|Line Numbers
  1. update table1
  2. set col07 = (select col02+col03+col04 from table1)
  3.  
this obviously doesnt work.
Error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

so can any1 help...?

Cheers James
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. update table1
  3. set col07 = col02+col03+col04
  4.  
  5.  
Dec 14 '07 #2
jamesd0142
469 256MB
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. update table1
  3. set col07 = col02+col03+col04
  4.  
  5.  
cheers m8 thats workin like a dream
Dec 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
4
by: Dave [Hawk-Systems] | last post by:
have a data table that records entries by date(unix timestamp) and customer number. each custnum will have several entries showing a running ledger type snapshot. we have the need to get the most...
3
by: RJN | last post by:
Hi I'm using the Dataadapter and Dataset to do an insert/update/delete into tables. The dataset has multiple tables in it. I want to write my own Update/Insert commands for the Dataadapter for...
6
by: Bill nguyen | last post by:
I use DatagridTableStyle to display data from table WF_Carrier_FreightChart. USers than can add/delete/edit rows in the Datagrid. Since the Datagrid's datasource "dCarrierFreight" is just a...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
2
by: eighthman11 | last post by:
Hi everyone. I am updating a table with aggregate results for multiple columns. Below is an example of how I approached this. It works fine but is pretty slow. Anyone have an idea how to...
1
by: Max2006 | last post by:
Hi, I am truing to find a pattern for my Business Logic Layer to be able to work fine win ObjectDataSource's Update method. The challenge is ObjectDataSource is not able to work with an...
5
by: Bogdan | last post by:
Hi, I have a stored procedure that uses JOINs to return columns from multiple tables. I also have another stored proc that that takes a series of params and updates multiple tables. I used the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.