Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Created July 2, 2009 20:33
Show Gist options
  • Save jimmybaker/139702 to your computer and use it in GitHub Desktop.
Save jimmybaker/139702 to your computer and use it in GitHub Desktop.
update sales_orders so
inner join users u on so.user_id = u.id
set so.sales_team_id = case u.sales_team_id
when 1 then
case so.shipto_state
when 'TN' OR 'AL' then 2
when 'TX' then 3
when 'GA' OR 'NC' OR 'SC' then 4
else 1
end
else u.sales_team_id
end
where so.state != 'pending'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment