+1  A: 

First create the index and second the foreign key constraint. MySQL needs an index to create the foreign key, that's why you have to create the index first. Use seperate statements as well.

Frank Heikens
i try to seperate but the same problem
Haim Evgi
Ah, I see, you try to give the index and the foreign key constraint the same name. Use unique names and it should work.
Frank Heikens
when i change the name and try run it i get an error : Error Code : 1452 Cannot add or update a child row: a foreign key constraint fails
Haim Evgi
Your data isn't correct, you try to make a match that isn't there. Clean up your data and try again. The syntax for creating the index and foreign key is now correct, that problem is solved.
Frank Heikens
ok i check this
Haim Evgi
you right, thank you
Haim Evgi