Link to home
Start Free TrialLog in
Avatar of staleb
staleb

asked on

Update dpending on combination of two columns

Hi
I have a table UserCompany:
CompanID
UserID
DefaultCompany

A user can have serveral rows in the table, connected to several Companies.
I want to update the row with the min(CompanyID) and set defauly = true:

I can select the rows:

Select min(CompanyID) as comp,UserID
from UserCompany uc
where DefaultCompany <> 1
group by UserID

But can seem to figure out how to update the same rows?




ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of staleb
staleb

ASKER

Thanks

I was so close, but still so far away