---------- Forwarded message ----------
From: Robert Klemme <[EMAIL PROTECTED]>
Date: 28.09.2005 14:08
Subject: Re: Problem with update Statement (very simple??)
To: Philipp Kemmer <[EMAIL PROTECTED]>


2005/9/28, Philipp Kemmer <[EMAIL PROTECTED]>:
>
>
> Hi,
>
> I really need your help. I have some problems with implementing an Update of 
> special rows in one of my tables:
>
> I have the following tables:
>
> "T1" with fields called "id" and "value"
>
> and a table "T2" with the fields "id" and "value"
>
> I want to update T1.value with T2.value where T1.id = T2.id,
>
> but only if the T2 contains the id.
>
> Here is the example:
>
>
>
> T1:
>
> id, value
>
> 1, 'A'
>
> 2, 'B'
>
> 3, 'C'
>
>
>
> T2:
>
> id, value
>
> 2, 'X'
>
>
>
> After the update T1 should be
>
> id, value
>
> 1, 'A'
>
> 2, 'X'
>
> 3, 'C'
>
> I first tried
>
> UPDATE "T1" SET "value" = (SELECT "T2"."value" FROM "T2" WHERE "T1"."id" = 
> "T2"."id")
>
>
>
> But here all rows (exept id=2) are set to NULL.

You can solve this by adding a WHERE clause to the UPDATE.

Other alternatives have been discussed recently in the news
http://groups.google.com/group/comp.databases.ms-sqlserver/browse_frm/thread/5d3fe7b4fe26e84a/
http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_frm/thread/cb38c777e9a57760/
http://groups.google.com/group/microsoft.public.sqlserver.server/browse_frm/thread/57348d389e2b7d91

Kind regards

robert

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to