Re: select query for duplicate records

2001-06-28 Thread Pete Kuczynski
That makes sense, sound like I'm redoing in PHP what the UNIQUE column already does. So all I need to do is modify my PHP trap using mysql_affected_rows() = 0, retun a error messagu to the used indicating a rcord already exists. Will try it, THX! Pete Paul DuBois wrote: > > At 5:46 PM -0500 6/27

Re: select query for duplicate records

2001-06-27 Thread Paul DuBois
At 5:46 PM -0500 6/27/01, Pete Kuczynski wrote: >Thanks Paul! >ps works great! >I modified the database with a UNIQUE column like you recommended >earlier, this will now help in the PHP script to trap the duplicate >entry and advise the user of the dup. But if hostname now has a UNIQUE index on i

Re: select query for duplicate records

2001-06-27 Thread Pete Kuczynski
Thanks Paul! ps works great! I modified the database with a UNIQUE column like you recommended earlier, this will now help in the PHP script to trap the duplicate entry and advise the user of the dup. 1 $result = mysql_query($query); // check if row is returned, if yes error, if

Re: select query for duplicate records

2001-06-27 Thread Bob Hall
>Hi, >How would a word a select statment, to search a database for duplicate >entries in one field. > >For example, the fields: device, hostname, IP, comments > >I want to find all instances where there my be two devices with the same >hostname. > >Thanks! > >Pete Sir, try the following. SELECT

Re: select query for duplicate records

2001-06-27 Thread Hannes Niedner
Peter, That comes pretty close to the distinct -thread in this mailinglist. You might want to try: SELECT device, count(hostname) FROM your_table GROUP BY device HAVING count(hostname)>1; This would display all devices with at least 2 (or more) hostnames. If you always have the same IP address,

Re: select query for duplicate records

2001-06-27 Thread Paul DuBois
At 3:13 PM -0500 6/27/01, Pete Kuczynski wrote: >Hi, >How would a word a select statment, to search a database for duplicate >entries in one field. > >For example, the fields: device, hostname, IP, comments > >I want to find all instances where there my be two devices with the same >hostname. SEL