Re: preventing duplicate entries

2001-06-26 Thread techlists

-- Original Message --
From: Pete Kuczynski [EMAIL PROTECTED]
Date: Tue, 26 Jun 2001 13:19:02 -0500

I want to prevent duplicate entries into my mysql database which holds
invertory of all network eqpt at my site. Engineers access it thru
netscape and the query insert is done via pdp [below].

I will place the script into php, any pointers on this would be
appreciated.

Why not make your inventory identifier field a unique index:
ie:
alter table inventory add unique itemid (itemid);

Now, whenever someone tries to create a duplicate item identifier,
MySQL will issue an error, which your script can capture.  I don't use PHP, but do use 
VB through MyODBC, and this is how I catch unwanted duplicates.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: preventing duplicate entries

2001-06-26 Thread techlists

-- Original Message --
From: Pete Kuczynski [EMAIL PROTECTED]
Date: Tue, 26 Jun 2001 14:02:08 -0500

My primary key field is a auto incremented index, the field I want to
make unique, or to say, prevent duplicates in, is the hostname field,
which has, hostnames of devices. Is the key word UNIQUE then? 

Not all of the devices have hostnames assigned to them, like terminals,
so the hostname field is blank in many cases. If I make that field
UNIQUE, will that cause a problem, with multiple blank fields?

I believe that a unique index field will permit Null values.

Aaron



(sql - these filters are really annoying!)


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php