An airline failing and two airlines merging are two very different scenarios. When an airline fails the pilots are laid off with the rest of the work force. Those pilots can use their experience and qualifications to go apply for new jobs, but they will be at the bottom of the seniority list of any airline that hires them.
When airlines merge the pilot seniority lists are blended in a way that is fair to each pilot group. There is no one set way of doing this as each airline is unique and brings different things to a merger, so typically a panel of three independent arbitrators will come up with a fair method if integration. I went through this as A Continental pilot when we merged with United. For me and for the rest of the pilot group the merger has been a great thing, it has opened a lot of new opportunities for us and the combined company is a lot healthier than the two independent ones were.