Can I update a group of records in a table from another group of records in the same table with one SQL statement?

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Thu Sep 17 02:04:53 CDT 2009


On 9/17/09 6:55 AM, "Barry G. Sumpter" <barrysum at bigpond.net.au> wrote:

Hi Barry,

> About two years ago you assisted me in writing a single sql statement
> to copy 100 records into a table from the same table.
> 
> I'd now like to update those records from data from the same table.
> 
> Is this allowed in Valentina?
> 
> 
> UPDATE myTable 
> ( myField1, myField2, myField3, myField4 )
> WHERE myTable.myField1 = 'UpdateTheseRecordsSelectionCriteria1'
> SELECT myField1, myField2, myField3, myField4
>   FROM myTable 
> WHERE myTable.Field1 = 'WithDataFromTheseRecordsSelectionCriteria2';

Wrong syntax I think.

<http://valentina-db.com/dokuwiki/doku.php?id=valentina:vcomponents:vsql:ref
erence:sqlgrammar#data_manipulation>

update_statement_searched
    : UPDATE table_name SET set_clause [, set_clause ...]
      [ WHERE search_condition ]

So I think there is no such command as you want.

Can you explain why you want it in single command?

Note, If you do not want write it in RB code,
You can CREATE PROCEDURE to execute this task on DB side.




-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list