I had a similar problem, but my criteria for selecting the
value of "f1" was different; it's a date field and I wanted
only the rows with the most recent date value in that field,
so only the "latest" of otherwise identical entries got inserted.
I ended up doing something like this:
create temporary table temp_table (
t_f1 date,
t_f2 varchar(100) unique,
t_f3 varchar(100) unique
);
insert ignore into temp_table
select f1,f2,f3 from new_table
order by f1 desc;
insert into original_table
select * from temp_table;
If there is a better way to do this, I would like to
know about it.
- seb
| Thread |
|---|
| • Can connect with PHP to MYSQL | leegold | 13 Aug |
| • Re: Can connect with PHP to MYSQL | suomi | 13 Aug |
| • Re: Can connect with PHP to MYSQL | Wesley Furgiuele | 13 Aug |
| • Re: Can connect with PHP to MYSQL | leegold | 13 Aug |
| • Re: Can connect with PHP to MYSQL | Andreas Ahlenstorf | 13 Aug |
| • SQL question, SELECT DISTINCT | leegold | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | SGreen | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | leegold | 16 Aug |
| • T-SQL SUM() Overflow? | David Mohorn | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | SGreen | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | leegold | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | Michael Stassen | 16 Aug |
| • RE: T-SQL SUM() Overflow? | Martin Gainty | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | leegold | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | Michael Stassen | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | leegold | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | leegold | 16 Aug |
| • Re: SQL question, SELECT DISTINCT | Stephen E. Bacher | 17 Aug |
| • Re: SQL question, SELECT DISTINCT | Michael Stassen | 17 Aug |