RE: [PHP-DB] Duplicate rows

2006-03-03 Thread Miguel Guirao
!! -Original Message- From: Ade Olonoh [mailto:[EMAIL PROTECTED] Sent: MiƩrcoles, 01 de Marzo de 2006 12:19 p.m. To: Miguel Guirao Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Duplicate rows Assuming you're using MySQL, instead of using INSERT INTO, you can use REPLACE INTO instead. If you have

[PHP-DB] Duplicate rows

2006-03-01 Thread Miguel Guirao
My dear beloved friends, I have a catalog of products that a product provider gave, sadly for me, in this CSV file there are many duplicated rows. I edited the file in my Linux system with the uniq -u command, and it worked somewhat fine, it eliminated some duplicated rows, originally the file

Re: [PHP-DB] Duplicate rows

2006-03-01 Thread Micah Stevens
SELECT DISTINCT * FROM `tablename` On Wednesday 01 March 2006 7:24 am, Miguel Guirao wrote: My dear beloved friends, I have a catalog of products that a product provider gave, sadly for me, in this CSV file there are many duplicated rows. I edited the file in my Linux system with the uniq

Re: [PHP-DB] Duplicate rows

2006-03-01 Thread tg-php
Depends on how you determine if something's a duplicate or not. For example, if it's just one column that can be used, you can do something like this: select ItemName, count(ItemName) from ItemListTable group by ItemName having count(ItemName) 1 That'll show you if ItemName is repeated.

Re: [PHP-DB] Duplicate rows

2006-03-01 Thread Ade Olonoh
Assuming you're using MySQL, instead of using INSERT INTO, you can use REPLACE INTO instead. If you have unique keys on that table, the new record will overwrite existing records with the same unique keys instead of creating a new one. http://dev.mysql.com/doc/refman/5.0/en/replace.html

Re: [PHP-DB] Duplicate rows

2006-03-01 Thread tg-php
Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all totally 100% unique records. If you had an auto_increment column though, you'd want to exclude it from the list. -TG = = = Original message = = = SELECT DISTINCT * FROM `tablename` On Wednesday 01 March 2006 7:24

Re: [PHP-DB] Duplicate rows

2006-03-01 Thread Micah Stevens
Ahh, good point, yes, keep in mind you may have some index rows.. On Wednesday 01 March 2006 10:18 am, [EMAIL PROTECTED] wrote: Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all totally 100% unique records. If you had an auto_increment column though, you'd want to

Re: [PHP-DB] Duplicate rows

2006-03-01 Thread Micah Stevens
err columns.. sorry.. On Wednesday 01 March 2006 10:45 am, Micah Stevens wrote: Ahh, good point, yes, keep in mind you may have some index rows.. On Wednesday 01 March 2006 10:18 am, [EMAIL PROTECTED] wrote: Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all