Skip to content

Instantly share code, notes, and snippets.

@mcloide
Created March 22, 2016 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcloide/2120477b045a7574db7b to your computer and use it in GitHub Desktop.
Save mcloide/2120477b045a7574db7b to your computer and use it in GitHub Desktop.
new-update-piratees
update piratees p
join (
select p1.id, min(ps.ship_in) as ship_in
from piratees p1
join piratee_login ps on ps.piratee_id = p1.id
where ps.ship_in is not null
and ps.ship_in > '1970-01-01 00:00:01'
group by p1.id
) as ps
on ps.id = p.id
set p.start_date = ps.ship_in
where p.start_date <= '1970-01-02'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment