Originally Posted by
wirickpiao
I should buy the ticket from the same airline that is operating the flight to avoid all this hassle.

Yep, you're right.
But it's also good knowledge to understand how mileage earning/crediting in this sort of situation.