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
How about
INSERT INTO original_table
SELECT MAX(f1), f2, f3 FROM new_table GROUP BY f2, f3;
Michael
Stephen E. Bacher wrote:
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
say I'm selecting distinct (non-duplicate) rows for insertion,
insert into original_table select distinct * from new_table
these tables have 3 fields/row. Per the above code all 3 fields are
evaluated by distict * .
But my question is: I want to ignore field1, therefore I only want to
test
It all depends on which values of f1 you want to ignore.
f1 f2 f3
- - --
val1-1 val2 val3
val1-2 val2 val3
val1-3 val2 val3
Which value of f1 would you want in your new table? Which ones to ignore?
Are there other columns (beyond these 3) to move as well?
On Mon, 16 Aug 2004 11:36:32 -0400, [EMAIL PROTECTED] said:
It all depends on which values of f1 you want to ignore.
f1 f2 f3
- - --
val1-1 val2 val3
val1-2 val2 val3
val1-3 val2 val3
Which value of f1 would you want in your new table? Which ones to
Let me see if I can explain it a little betterIf you need to move all
3 columns to the new table but you only want *1* row where f2 and f3 have
a unique combination of values, how do you want to choose *which* value of
f1 to move over with that combination? Do you want the minimum value,
On Mon, 16 Aug 2004 12:39:32 -0400, [EMAIL PROTECTED] said:
Let me see if I can explain it a little betterIf you need to move all
3 columns to the new table but you only want *1* row where f2 and f3 have
a unique combination of values, how do you want to choose *which* value
of
f1 to
You were perfectly clear. We understand that you only want to test f2 and
f3 for uniqueness. The question is, which of the possible values of f1 do
you want to get. Do you see? For a particular unique f2, f3 combination,
there may be multiple f1 values. How should we choose which one to
On Mon, 16 Aug 2004 13:57:13 -0400, Michael Stassen
[EMAIL PROTECTED] said:
You were perfectly clear. We understand that you only want to test f2
and f3 for uniqueness. The question is, which of the possible values
of f1 do you want to get. Do you see? For a particular unique f2, f3
Then I'd suggest you declare f1 as an AUTO_INCREMENT column in the target
table, leave it out of the SELECT, and let it auto-generate IDs. Something
like this:
INSERT INTO original_table (f2, f3)
SELECT DISTINCT f2, f3 FROM new_table;
I did that in the same order as your original message,
On Mon, 16 Aug 2004 13:57:13 -0400, Michael Stassen
[EMAIL PROTECTED] said:
You were perfectly clear. We understand that you only want to test f2
and f3 for uniqueness. The question is, which of the possible values
of f1 do you want to get. Do you see? For a particular unique f2, f3
Disregard by last message it's a repeat. THANKS for the help!
On Mon, 16 Aug 2004 14:32:27 -0400, Michael Stassen
[EMAIL PROTECTED] said:
Then I'd suggest you declare f1 as an AUTO_INCREMENT column in the target
table, leave it out of the SELECT, and let it auto-generate IDs.
Something
12 matches
Mail list logo