How to update columns from row to another row? (thank you)

 
assume my Table's Columns looks like below

1  ,   Annie,   History, pass, null
2  ,   Colin,   Math   , Pass, null
7  ,   Annie,   History, Fail, 1
11 ,   Colin,   Math   , Fail, 2

When Delete
7  ,   Annie,   History, Fail, 1
11 ,   Colin,   Math   , Fail, 2

using the last column to check which row is reference with it
so when delete Row 7 which reference with
1  ,   Annie,   History, pass, null
when delete Row 11 which reference with
2  ,   Colin,   Math   , Pass, null

if I gooing to delete the row of No7 the result would be
1  ,   Annie,   History, Fail, null  
2  ,   Colin,   Math   , Pass, 0
11 ,   Colin,   Math   , Pass, 0

if I going to delete the row of No11 the result would be


1  ,   Annie,   History, pass, null
2  ,   Colin,   Math   , Pass, null
7  ,   Annie,   History, Fail, 1


I think the simply way to explan is
when you delete a row of data , first find out which row is reference with it and then update the row which reference with it

can you teach me how to do it ? wirte this request in Code or useing SQL Script?
thank you

0
jcjcjc
1/31/2008 6:47:49 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
524 Views

Similar Articles

[PageSpeed] 35

I'm not sure I understand your question.  Do you only want to delete a record once is has a referenced record?  So delete record 7 once record 1 exists???  And you can determine that a record has a referenced record because the 5th column has a value?  What are you updating in the first record?


- Corwin
(My Blog - www.ballhead.com/corwin)
0
Corwin
1/31/2008 2:40:24 PM
Reply:

Similar Artilces:

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

is it possible to turn 1 column,many rows into one row,many columns in sql ?
 Hi AllI have the following query:Select CategoryName From Category Where CategoryId In(Select SkillId From SpecialitySkills Where CopywriterId = 13) It gives me the correct results but not in the form that i want, i would like it to be in one row, many columns. its in 1 column, many rows.Any ideas?  You must be talking about displaying it on a web page? Just create a loop that runs through the rows of the data that is returned then just make html table:dim tablestring as string = "<table><tr>" for i as integer = 0 to dt.rows.count - 1 tablestring += &...

DataSet rows being deleted, but after the update , the sql database is not updated. The delete rows still in the database.
 Stepping thru the code with the debugger shows the dataset rows being deleted.   After executing the code, and getting to the page presentation. Then I stop the debug and start the page creation process again ( Page_Load ).    The database still has the original deleted dataset rows. Adding rows works, then updating works fine, but deleting rows, does not seem to work.   The dataset is configured to send the DataSet updates to the database. Use the standard wizard to create the dataSet.     cDependChildTA.Fill(cDependChildDs._ClientDependentC...

Row updating, row updated confusion
Okay this is the first time I've ever had to do code behind for row updating logic in a gridview. So be patient with me if it's totally incorrect. Do I put the gridview rebind code in the Row Updating or Updated event?  Currently, I have it in both as I'm simply troubleshooting to try to get it to work.  With this code, not only is the record not updating but the record disappears from the gridview upon refreshing.Protected Sub GridView2_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles GridView2.RowUpdated ...

How to transform SQL output rows into GridView rows+columns?
This is somewhat tricky to explain. What I am trying to do is link the output from a SQL query that is grouped into rows and turn that into a set of rows and columns. ex: turn this (from SQL): sqlcol1sqlcol2sqlcol3 row_1 col_a 1 row_1 col_b 2 row_1 col_c 3 row_2 col_a 4 row_2 col_b 5  into this (in GridView):  col_acol_bcol_c row_1 1 2 3 row_2 4 5     I am thinking that the best way of doing this is to inherit from GridView and to write a custom metho...

How to go through a datatable row by row and column by column
Hello, I have a dataset with a datatable and I need to insert each row from the datatable on my sql table, anyway there may be errors, so some rows may not be inserted because primary key constraints,  So I need to show the rows that are not inserted in a gridview, the hard thing to do is to go through all the datatable,  is there an wasy way to do it?MCPD ENTERPRISE APPLICATION DEVELOPER Start by looking herehttp://msdn2.microsoft.com/en-us/library/system.data.common.dataadapter.update.aspxPerform an update of your dataset, and if a row fails, you can mark it as invalid.You can ...

question about updating a row? How to update a different row.
I will try to make this as simple as I can. k, here I go. I originally populate my datagrid with data. Then during the edit mode, I can populate information by an ontextchanged event, which is actually bringing in a new row (essentially). My problem occurs when I try to update the data. Since the row was originally populated with the data, it updates that row in the table. But since I did an ontextchanged, I want to update that row instead. Not the original row. If I do an update, then I have two identical rows of data in my table, but with different primary keys. How can I update t...

Stored Procedure that fetch each row of a table and update rows in another table
I am working with the following two tables: Category(NewID,OldID) Link(CategoryID,BusinessID) All fields are of Integer Type. I need to write a stored procedure in sql 2000 which works as follows: Select all the NewID and OldID from the Category Table (SELECT NewID,OldID FROM Category) Then for each rows fetched from last query, execute a update query in the Link table. For Example, Let @NID be the NewID for each rows and @OID be the OldID for each rows. Then the query for each row should be.. UPDATE Link SET CategoryID=@CID WHERE CategoryID=@OID Please help me ...

update multi row when i meant update single row
RGVhciBhbGw6DQoNCkkgdHJpZWQgdG8gdXBkYXRlIGEgc2luZ2xlIHJvdyBmb3IgdGhlIGRh dGFiYXNlLCBob3dldmVyLCB0aGUgcXVlcnkgaGVyZQ0KdXBkYXRlIG11bHRpcGxlIHJvd3MN Cg0KbXkgJHNxbCA9ICJVUERBVEUgdXB0aW1lIFNFVCB1cF90aW1lPSRuZXdfdXB0aW1lDQog ICAgICAgICAgICAgV0hFUkUgaG9zdG5hbWUgPSAnJGhvc3QnIGFuZA0KICAgICAgICAgICAg IHN0YXJ0ZGF0ZT0gKHNlbGVjdCBNQVgoc3RhcnRkYXRlKSBmcm9tIHVwdGltZSB3aGVyZQ0K ICAgICAgICAgICAgIGhvc3RuYW1lID0nJGhvc3QnIGFuZCB1cF90aW1lID0gJG9sZHVwdGlt ZSkgIjsNCg0KSSBtZWFudCBvbmx5IHdhbnQgdG8gdXBkYXRlIGxhdGVzdCBzdGFydGRhdGUs IHNvbWVob3csIGl0IHJldHVybnMgYWxsDQp0aGUgc3RhcnRkYXRlIHdoaWNoIHVwX3RpbWUg PSRvbGR1...

warning: update row ... is a conflict update and this row is ignored
SQL Anywhere 10.0.1.3488 I am synching one SQL Anywhere database to another through MobiLink, getting this warning: W. 2008-08-19 13:01:01. <17> [10037] Ignoring updated row (new values) W. 2008-08-19 13:01:01. <17> [10038] Ignoring updated row (old values) W. 2008-08-19 13:01:01. <17> [10072] The update row for table '<orders>' is a conflict update and this row is ignored. There are currently no conflict resolution scripts in place, so I would expect the default behavior of "last one in wins" rather than seeing "this row is ign...

Arranging data on multiple rows into a sigle row (converting rows into columns)
Hello, I have a survey (30 questions) application in a SQL server db. The application uses several relational tables. The results are arranged so that each answer is on a seperate row: user1   answer1user1   answer2user1   answer3user2   answer1user2   answer2user2   answer3 For statistical analysis I need to transfer the results to an Excel spreadsheet (for later use in SPSS). In the spreadsheet I need the results to appear so that each user will be on a single row with all of that user's answers on...

Updating DataList Row by Row
Hello, I have a datalist on my web page which displays a list of records from my database, all the information is displayed in labels except for one which is in a DropDownBox and the user can select Yes or No.  I want to update each record individual based on the value in the dropdownbox.  My problem is currently if I change the last record to say No then all the records in the db change to No.  It is not recording the new values row by row. Anybody got ideas why? ThanksRegards,Steven I don't think is the DataList because I used in that way myself many times Post som...

(Fwd) How to loop through a database, row by row, and select and update one row at a time
----- Forwarded message from Troy Mulder <mulderta@gmail.com> ----- Date: Mon, 12 Apr 2010 17:48:37 -0400 From: Troy Mulder <mulderta@gmail.com> To: Tim.Bunce@pobox.com Subject: How to loop through a database, row by row, and select and update one row at a time Hello Tim (is it Dr. Bunce?), My name is Troy Mulder, and I am trying to get a perl script to interface with a PostgreSQL database. I am trying to step through each row of the database, and read one column of the row, and update another column of the row. When I follow the online tutorial a...

computing the difference of a column in the current row from the column of the preceding row
Hello, a user asked me if we can solve following problem: we want to compute the difference (delta) of a column in the current row from the column of the preceding row. My first solution signs where: create a computed field (small_function_result) that takes the value from the preceding row: small(value, value, cf_getrow for all); where cf_getrow is a computed field like this: if(getrow()=1,getrow(),getrow()-1) create a computed field (Diff) that computes the difference: value-small_function_result My results should look like this: Row Value cf_getrow small_func...

Web resources about - How to update columns from row to another row? (thank you) - asp.net.sql-datasource

Politics, Political News - The Capitol Column
Covering the politics of science, technology, business, entertainment, Capitol Hill, and health.

Column (typography) - Wikipedia, the free encyclopedia
In typography , a column is one or more vertical blocks of content positioned on a page, separated by gutters and/or rules . Columns are most ...

Column 8: 'Don't order anything'
A word of warning about the true meaning of Australia Post's 'Hold Mail' service from Brian Jeffrey, of Cook, ACT.

Column 8: 'I am the Jenny doll'
&quot;I am the Jenny doll, and was a flight attendant with Qantas for 13 years,&quot; writes Jennie Leroy (nee Tregaskis, Column 8, Monday). ...

Paris attacks: column in IS magazine warns of 9/11-scale attack to come
Under the byline of a hostage British journalist, Islamic State warns that it may attempt a terrorist attack even bigger than 9/11.

Column 8: More weird 'hotel signage'
&quot;I have more weird 'hotel signage',&quot; offers George Watson, of Grafton (Column 8, Thursday). &quot;The following was posted on the wall ...

The 10 Best Online Columns Of All Time . . .
Former Biglaw partner and inhouse columnist Mark Herrmann identifies the ten best online columns of all time.

Should the Washington Post’s Ties to Reagan Library Be Disclosed in Columns Attacking Bill O’Reilly?
Much has been discussed regarding the recent spat between Washington Post columnist and Fox News contributor George Will and Fox News host and ...

Mark Bittman's "Fast Company" Column Starts Today
The best-selling author and Emmy award-winning TV personality is writing about his startup experiences exclusively for Fast Company . The influence ...

ISIS militants tie captives to Palmyra's columns before blowing them up
ISIS militants tie captives to Palmyra's columns before blowing them up

Resources last updated: 11/25/2015 10:14:20 AM