I did lot of test but still have the problem that I’m not able to avoid duplicate record.
The existing index do not block duplicate (???).
I don’t know how to fix it .
My mySQL table has an ID field
memberID int(11) No None AUTO_INCREMENT
…
…
and these two INDEXes (1st primary and 2nd unique)
PRIMARY__________________BTREE S? No memberID 1 A
key_Name_Year_Meccan_____BTREE S? No contactLastName 1 A
_____________________________________________memberName 1 A
_____________________________________________year_card_actual 1 A
_____________________________________________national_federationID 1 A
This is my query for upload new records or update existing ones (with same index key_Name_Year_Meccan). No way it wants to work ;-((
$sql_insert_update_members = "
INSERT IGNORE INTO members(
officeID , section_ID , registration_typeID , new_renewal , memberName , contactLastName , userName , titleID , borndate , bornplace , borncountry , sexID , citizenshipID , phone , fax , mobile01 , mobile02 , addressLine1 , addressLine2 , e_mail , fbname , twname , skype , image , city , state , postalCode , country , vatcode , residence , fiscalcode , national_federationID , medical_date , subscr_date , year_card , year_card_actual , member_card , license_card_01 , license_card_02 , license_card_03 , license_card_04 , license_card_05 , affiliated01 , affiliated02 , affiliated03 , affiliated04 , affiliated05 , category_01 , category_02 , shirt_name , shirt_number , shirt_size , pants_size , helmet_size , boots_size , gloves_size , insert_date
)
SELECT
officeID , section_ID , registration_typeID , new_renewal , memberName , contactLastName , userName , titleID , borndate , bornplace , borncountry , sexID , citizenshipID , phone , fax , mobile01 , mobile02 , addressLine1 , addressLine2 , e_mail , fbname , twname , skype , image , city , state , postalCode , country , vatcode , residence , fiscalcode , national_federationID, medical_date , subscr_date , year_card , year_card_actual , member_card , license_card_01 , license_card_02 , license_card_03 , license_card_04 , license_card_05 , affiliated01 , affiliated02 , affiliated03 , affiliated04 , affiliated05 , category_01 , category_02 , shirt_name , shirt_number , shirt_size , pants_size , helmet_size , boots_size , gloves_size , NOW()
FROM members_fim_csv
ON DUPLICATE KEY
UPDATE
members.new_renewal = members_fim_csv.new_renewal ,
members.borndate = members_fim_csv. borndate ,
members.sexID = members_fim_csv.sexID ,
members.citizenshipID = members_fim_csv.citizenshipID ,
members.phone = members_fim_csv.phone ,
members.fax = members_fim_csv.fax ,
members.mobile01 = members_fim_csv.mobile01 ,
members.addressLine1 = members_fim_csv.addressLine1 ,
members.e_mail = members_fim_csv.e_mail ,
members.city = members_fim_csv.city ,
members.residence = members_fim_csv.residence ,
members.subscr_date = members_fim_csv.subscr_date,
members.update_date = NOW()
";