The SQL Server version of this query is this:

UPDATE t1
  FROM MyTable   t1
   SET Foo = 1
 WHERE Bar = 99
   AND NOT EXISTS
       (
         SELECT *
           FROM MyOtherTable t2
          WHERE t2.SomeColumn   = t1.SomeColumn
            AND t2.SomeOtherColumn = t1.SomeOtherColumn
            AND t2.YetAnotherColumn   = 42
       )


The Oracle version is this:

UPDATE
(
   SELECT *
     FROM MyTable   t1
    WHERE Bar = 99
      AND NOT EXISTS
          (
            SELECT *
              FROM MyOtherTable t2
             WHERE t2.SomeColumn   = t1.SomeColumn
               AND t2.SomeOtherColumn = t1.SomeOtherColumn
               AND t2.YetAnotherColumn   = 42
          )
) join_table
SET join_table.Foo =   1


(Hopefully I didn't mess things up converting from real names and
simplifying a bit. Sorry about the bent indentation too; try it in a
monospace font.)

What's the MySQL version? Neither of those. All the examples on the
net are simple joins, not like this. Any other more reasonable ways to
do this, ideally something compatible with all three dbs (hah)?

Thanks,
Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338713
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to