0

Possible Duplicate:
Remove Duplicate Rows Leaving Oldest Row Only?
MySQL remove duplicate rows

Say that I have the following table coolumns: int logicalid(pk) ,int home, int person say the I have the following records...
1,5,6
2,5,6
3,5,5
4,5,5

After my query, I want to place into the new table only one row with the same home,person column values so this will be the output result:
1,5,6
2,5,5
Any ideas??

0

2 Answers 2

1

Create your new table with an auto-increment column for the id.

Then insert into the table, using a query such as:

insert into newTable(home, person)
    select distinct home, person
    from oldTable
0

INSERT INTO newtable(home, person) SELECT DISTINCT home, person FROM sourcetable

Not the answer you're looking for? Browse other questions tagged or ask your own question.