MySQL Forums
Forum List  »  Newbie

Re: UPDATE Table 1 with JOIN Table 2
Posted by: Peter Brawley
Date: August 02, 2015 08:11PM

> create a table that only includes the earliest entry for each individual.

Identified by id?

This identifies the desired rows:

select id,min(date_of_entry) as first
from tbl
group by id;

To make the new table ...

drop table if exists newtbl;
create table newtbl
select a.col1, a.col2, ...  -- all desired columns
from tbl a
join (
  select id,min(date_of_entry) as first
  from tbl
  group by id
) b on a.id=b.id and a.date_of_entry=b.first;

Options: ReplyQuote


Subject
Written By
Posted
Re: UPDATE Table 1 with JOIN Table 2
August 02, 2015 08:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.