On Mon, Jul 19, 2010 at 10:14:30AM +0530, Peter wrote:

> Hi All,
>
> I have a  table which contain's some duplicate rows. I just want to
> delete the duplicate records alone
> not original records.
>
> Assume my table as look as below
>
> column1 column2
> 1
>       a
> 1
>       a
> 2
>       b
> 3
>       c
> 3
>       c
>
>
>
> i want the above table need  to be as below, After executing the mysql
> query.
>
> column1
>       column2
> 1
>       a
> 2
>       b
> 3
>       c
>
>

If you're looking for a MySQL solution to this, this is the wrong list
to ask the question on. In fact, I'd be surprised to find a MySQL query
which would do this.

For a PHP solution, you'll need to query MySQL for all the rows, in
order by the column you want to use to kill duplicates. Then loop
through the rows one at a time in PHP, checking the contents of that
column against the last iteration. If they are the same, issue a DELETE
command in MySQL. Continue the loop until all rows are exhausted.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to