Jason - you posted this a 5 weeks ago and received several answers.

You say you have written your own code, but you have not attached it.

As Peter said, the key is probably to declare those columns unique then allow the database to determine whether to change those entries using REPLACE INTO not INSERT INTO.

Please do not keep re-posting the same problem. Instead, state what you tried, how you tried to debug it, and why it didn't work. Then maybe somebody will offer to spend more time on your problem, or offer to do it for a small fee ;-)

At 07:18 04/02/2004 +0000, you wrote:
Date: Tue, 03 Feb 2004 12:49:44 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Subject: multiple fields all unique?

I am running into a problem and I have yet to find an elegant solution for it.

I have three fields in a database that cannot have duplicates of these particular fields.

| hostname | mac               | ip             |
| pmac-1   | 00:30:65:6c:ea:cc |  |
| pmac-2   | 00:30:65:6c:e0:cc |  |

Now I have a simple form that opens up a record and allows users to modify 2 of the 3 fields, mac & ip.

In order for the user to save the record and overwrite the current contents of the database I first need to do a check to see if any of the 2 fields being updated match an existing record.

For example say the user modifies the ip field from to, because there is an entry that matches that change the record does not update, or vice versa for the mac fields.

Has anyone every performed such a feat as to check for matching fields before updating? And if so could you show me some code that used to accomplish this. I have written my own but the if - else statements are getting ridiculous.


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

Reply via email to