Click here to Skip to main content
15,890,123 members
Home / Discussions / Database
   

Database

 
GeneralRecords appear out of order Pin
Andrew Hain28-Jul-05 23:23
Andrew Hain28-Jul-05 23:23 
GeneralRe: Records appear out of order Pin
Marc Soleda29-Jul-05 0:55
Marc Soleda29-Jul-05 0:55 
GeneralRe: Records appear out of order Pin
Andrew Hain29-Jul-05 5:13
Andrew Hain29-Jul-05 5:13 
GeneralRe: Records appear out of order Pin
Toni7830-Jul-05 16:08
Toni7830-Jul-05 16:08 
QuestionBest Aproach When Working with Crystal Reports .Net? Pin
korso_rogan28-Jul-05 21:34
korso_rogan28-Jul-05 21:34 
GeneralImport Data Pin
cberam28-Jul-05 19:10
cberam28-Jul-05 19:10 
GeneralDate Format in the Database Pin
Anonymous28-Jul-05 19:09
Anonymous28-Jul-05 19:09 
GeneralComplex update Pin
Luis Alonso Ramos28-Jul-05 9:20
Luis Alonso Ramos28-Jul-05 9:20 
Hello,

I want to perform a query like this:
UPDATE Payment SET Week = (SELECT Week FROM Receipt WHERE Payment = Payment.ID)
Basically, the idea is that I have a table of payments, and a table of receipts, each receipt marked with a week number.

Now, I want to get the week number of the receipt for each payment, and put it in the Payments table.

To make things harder, there are two different receipts tables, and only one of the contains a receipt for a specific payment.

In pseudocode, it would be something like this:
foreach(paymentRow in Payments table)
{
    WeekNum = SELECT Week FROM Receipts where ID_payment = paymentRow.ID_payment
    IF WeekNum = NULL
    {
        WeekNum = SELECT Week FROM OtherReceipts WHERE ID_payment = paymentRow.ID_payment
    }
 
    IF WeekNum != NULL
        UPDATE paymentRow SET Week = WeekNum
}
It a once-in-a-lifetime update, so it doesn't have to be the best, performance-speaking.

So, any ideas?

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralRe: Complex update Pin
Edbert P28-Jul-05 13:25
Edbert P28-Jul-05 13:25 
GeneralRe: Complex update Pin
Luis Alonso Ramos28-Jul-05 13:29
Luis Alonso Ramos28-Jul-05 13:29 
GeneralRe: Complex update Pin
Edbert P28-Jul-05 13:34
Edbert P28-Jul-05 13:34 
GeneralRe: Complex update Pin
Luis Alonso Ramos28-Jul-05 13:42
Luis Alonso Ramos28-Jul-05 13:42 
GeneralRe: Complex update Pin
Edbert P28-Jul-05 13:54
Edbert P28-Jul-05 13:54 
GeneralRe: Complex update Pin
Luis Alonso Ramos28-Jul-05 14:03
Luis Alonso Ramos28-Jul-05 14:03 
QuestionHow to open a sql 2005 database in sql server 2005 Pin
playout28-Jul-05 1:26
playout28-Jul-05 1:26 
AnswerRe: How to open a sql 2005 database in sql server 2005 Pin
Not Active29-Jul-05 11:54
mentorNot Active29-Jul-05 11:54 
GeneralConnection string Pin
SeLoRBIS28-Jul-05 1:17
SeLoRBIS28-Jul-05 1:17 
GeneralRe: Connection string Pin
Marc Soleda28-Jul-05 5:54
Marc Soleda28-Jul-05 5:54 
GeneralRe: Connection string Pin
SeLoRBIS30-Jul-05 8:16
SeLoRBIS30-Jul-05 8:16 
GeneralRe: Connection string Pin
Marc Soleda31-Jul-05 21:00
Marc Soleda31-Jul-05 21:00 
GeneralRe: Connection string Pin
SeLoRBIS5-Aug-05 7:41
SeLoRBIS5-Aug-05 7:41 
GeneralRe: Connection string Pin
Marc Soleda7-Aug-05 20:18
Marc Soleda7-Aug-05 20:18 
GeneralUrgent !regarding sqlDataAdapter.Update Method Pin
Madni Abbasi28-Jul-05 0:31
Madni Abbasi28-Jul-05 0:31 
GeneralDB choice Pin
Marc Soleda27-Jul-05 22:33
Marc Soleda27-Jul-05 22:33 
GeneralRe: DB choice Pin
Hesham Amin29-Jul-05 2:47
Hesham Amin29-Jul-05 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.