PeterPan
9-23-06, 11:55 AM
Hi, i have a table.. with 7-8 fields...
Now, 3 of my fields, I want to be unique, however no INDIVIDUAL field
will be unique...
IE I can have values
Smith, 7, 8, (& extra fields here...)
Smith, 7, 5, (& extra fields here...)
Smith, 6, 5, (& extra fields here...)
Smith, 6, 3, (& extra fields here...)
John, 6, 5, (& extra fields here...)
Ie the 3 fields can have duplicate entries - two '5's' in the 3rd column, etc..
multiple Smiths etc...
HOWEVER, I do not want two lots of
Smith, 6, 5, (& extra fields here...)
Smith, 6, 5, (& extra fields here...)
QUESTION
Is there a way we can use the INSERT command, - But compare the 3
fields, & see if there is already a table entry with that
combination...
and only insert a new row, if there is no match for ALL 3 of the first
3 fields....
Or - Will I need to do a SELECT command - & then loop through the
array & see if it exists already...
Does this make sense ?
PS - I am already doing a SELECT - & adding toa n array - & looping through them...
According to my PHP code, & the scrteduled tasks logs (& onscreen printout..) - The values are NOT being added..
But - When I go into phpmyadmin screen - I do see dupes...
any advise ?
Now, 3 of my fields, I want to be unique, however no INDIVIDUAL field
will be unique...
IE I can have values
Smith, 7, 8, (& extra fields here...)
Smith, 7, 5, (& extra fields here...)
Smith, 6, 5, (& extra fields here...)
Smith, 6, 3, (& extra fields here...)
John, 6, 5, (& extra fields here...)
Ie the 3 fields can have duplicate entries - two '5's' in the 3rd column, etc..
multiple Smiths etc...
HOWEVER, I do not want two lots of
Smith, 6, 5, (& extra fields here...)
Smith, 6, 5, (& extra fields here...)
QUESTION
Is there a way we can use the INSERT command, - But compare the 3
fields, & see if there is already a table entry with that
combination...
and only insert a new row, if there is no match for ALL 3 of the first
3 fields....
Or - Will I need to do a SELECT command - & then loop through the
array & see if it exists already...
Does this make sense ?
PS - I am already doing a SELECT - & adding toa n array - & looping through them...
According to my PHP code, & the scrteduled tasks logs (& onscreen printout..) - The values are NOT being added..
But - When I go into phpmyadmin screen - I do see dupes...
any advise ?