No subject


Tue Aug 28 17:24:13 MST 2007


B
WHERE A.ACCOUNT_ID =3D B.ACCOUNT_ID)

Joseph Sinclair wrote:
> UPDATE TABLEA
> SET (b, c, d) =3D (SELECT b1, c1, d1 from TABLEB WHERE TABLEB.a1 =3D=20
> TABLEA.a and TABLEB.e1 > 40) WHERE EXISTS (SELECT 1 from TABLEB WHERE=20
> TABLEB.a1 =3D TABLEA.a and TABLEB.e1 > 40);
>=20
> Not pretty, but should work.
> You also might find this to work MUCH better as a stored procedure
using a cursor...
>=20
> Bryan O'Neal wrote:
>> IBM DB2
>> =20
>>
>> -----Original Message-----
>> From: plug-discuss-bounces at lists.plug.phoenix.az.us
>> [mailto:plug-discuss-bounces at lists.plug.phoenix.az.us] On Behalf Of=20
>> Joseph Sinclair
>> Sent: Friday, May 23, 2008 7:09 PM
>> To: Main PLUG discussion list
>> Subject: Re: SQL Help - update query with two tables
>>
>> What's the server (i.e. Oracle, MySQL, PostgreSQL, etc...)
>>
>> Bryan O'Neal wrote:
>>> I have not done SQL by hand since sometime in 2005/2006 and I can=20
>>> not remember how to do a dynamic update using more then one table.
>>> =20
>>> Let us say I have a table A and a table B and I want to update a=20
>>> record in table A for every record in table b base on information in
>> table B.
>>> For example, let us say I want A.CURRENT_BALANCE to be set to=20
>>> A.CURRENT_BALANCE + B.DEPOSIT where A.ACCOUNT_ID =3D B.ACCOUNT_ID.
>>> =20
>>> Thoughts?
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> --
>>> --
>>>
>>> ---------------------------------------------------
>>> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>>> To subscribe, unsubscribe, or to change your mail settings:
>>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>
>=20
>=20
> ----------------------------------------------------------------------
> --
>=20
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss



More information about the PLUG-discuss mailing list