using UPDATE with GROUP By

william humphrey bill at bluewatermaritime.com
Sun Jun 20 10:13:59 CDT 2010


Spoke to soon.  The following doesn't work as expected:

UPDATE data_address SET d_address_LineNumber = 2 WHERE
d_address_LineNumber IN (select d_address_LineNumber from
(select d_address_LineNumber, d_address_clients_ref, count
(d_address_clients_ref) as SomeName
from data_address
group by d_address_LineNumber,d_address_clients_ref
having SomeName > 1)
))

It set all the records of d_address_LineNumber to 2 except the one
which was already set as 1 so even though when you look at the
subquery it works fine as a SELECT but the UPDATE does not work as
expected. So I'm back to square one.


More information about the Valentina mailing list