One ground of demurrer is that the complaint does not state facts sufficient to constitute a cause of action against the appellant. There can be no question but that the complaint states a good cause of action for the foreclosure of the mortgage. That is the primary object of the action. The statute authorized the plaintiff to unite in such action a demand for judgment for any deficiency on the sale “against every party” who might “be personally liable for the debt secured by the mortgage, whether the mortgagor or other persons, if upon the same contract which the mortgage was g'iyen to secure.” Sec. 3156, Stats. 1898. There can be no question but that the four makers of the note and mortgage (including the appellant) were personally liable upon the same contract which the mortgage was given to secure. The defendarit O’Hearn, having purchased the mortgaged premises from the mortgagors and, in the deed to him, having as*412sumed and agreed to pay tbe mortgage, debt as a part of tbe purchase price, thereby became personally liable upon tbe same contract which the mortgage was given to secure, and hence is a proper defendant in this action. This has, in effect, been repeatedly held by this court. Palmeter v. Carey, 63 Wis. 426, 21 N. W. 793, 23 N. W. 586; Stites v. Thompson, 98 Wis. 329, 332, 73 N. W. 774; Halbach v. Trester, 102 Wis. 530, 78 N. W. 759; Kuener v. Smith, 108 Wis. 549, 84 N. W. 850; Carpenter v. Meachem, 111 Wis. 60, 62, 63, 86 N. W. 552. The same is true as to the personal liability of the defendant Le Clair, who, with R. C. Jones, deceased, received a dee$ of the premises from O’lleam and wife, and therein assumed and agreed to pay the mortgage debt. The several parties named are all interested in having the mortgaged premises bring as large a price on such sale as possible, in order to save themselves, wholly or in part, from such personal liability. The statute cited requires “such judgment for deficiency” to “be ordered in the original judgment and separately rendered against the party liable on or after the coming in and confirmation of the report of sale, and be docketed and enforced as in other cases.” Sec. 3156, Stats. 1898. The manifest purpose of the statute is to have the rights of all parties interested fully determined in the action to foreclose the mortgage.
Had the note and mortgage been foreclosed by the original mortgagee, or the Northern Trust Company or Mary A. Mc-Nealy, there could have been no doubt but that the makers of the note might ail have been held personally liable thereon. But it is claimed that as the plaintiff was one of the makers of the note and mortgage, and had purchased the same, he was thereby precluded from maintaining an action against his co-makers on the note, and that, if this be regarded as an action for contribution by one of the makers of the note against the other three, then such action for contribution cannot be joined with an action to foreclose the note and mort*413gage. There can be no question but that, after the sale of the mortgaged, premises, Le Clair and. O’EEearn would be primarily liable for any deficiency. The makers of the note and mortgage were secondarily liable for any deficiency. They, or any of them, had the right to protect themselves by purchasing the note and mortgage. 1 Jones, Mortgages, § 768; Mills v. Watson, 1 Sweeney, 374; Baker v. Terrell, 8 Minn. 195 ; Muir v. Berkshire, 52 Ind. 151. Thus it has been held in New York that:
“If the holder of a bond and mortgage assigns them to a party claiming a right to redeem, the latter is subrogated by the assignment to the mortgage debt and mortgage security, and to the instruments evidencing such debt and security, and there is no room or occasion for subrogation by operation of law.” Ellsworth v. Lockwood, 42 N. Y. 97, cited approvingly in 1 Jones, Mortgages, § 874.
In another case in the same state it was held that:
“Where one who pays a mortgage upon land in which he has an interest stands in such a relation thereto that his interest, whether legal or equitable, cannot otherwise be adequately protected, the transaction will be treated in equity as an assignment, and he is entitled to enforce it for his own reimbursement and the protection of his interest.” Arnold v. Green, 116 N. Y. 566, 23 N. E. 1.
So it has been held in Michigan that:
“Where property owned by two partners is subject to a mortgage and, as between the two, it is the duty of one to discharge it, and the other pays the debt on condition that the mortgage shall inure to his benefit, an equity arises in his favor, entitling him to indemnity through the mortgage.” Laylin v. Knox, 41 Mich. 40, 1 N. W. 913.
So it has been held in Vermont that:
“Where a partner mortgages his private property to secure a partnership debt, which is also secured by a mortgage on the partnership property, he stands surety for the partnership, and is entitled to be subrogated to the rights of a mortgagee, and the creditors of such surety are entitled to the same *414right of subrogation as the surety himself; the partnership property being a primary fund, the private property a collateral pledged to pay the debt.” National Bank v. Cushing, 53 Vt. 231.
See, also, Levy v. Marlin, 48 Wis. 198, 4 N. W. 35; Stewart v. Stewart, 90 Wis. 516, 63 N. W. 886. So this court has held that:
“One of several sureties who has paid a judgment against all may maintain an action in equity to enforce contribution from his co-sureties, and may be subrogated to all the rights of the creditor under the judgment.” Mason v. Pierron, 63 Wis. 239, 23 N. W. 119. '
This is an equitable action, and we perceive no good reason why the plaintiff is not subrogated to the rights of his assignors; except in so far as he is equitably liable, nor why the rights of the respective parties should not be determined in this action. Certainly the three defendants who signed the note were not discharged of liability by the mere fact that the plaintiff purchased the note and mortgage. Of course, the plaintiff could in no event recover from them anything more than their equitable proportion of such deficiency. We must hold that the complaint states a cause of action against the parties named, including the appellant. We fail to find any misjoinder of causes of action in the complaint, or any defect of parties, defendant. The demurrer was properly overruled.
By the Court. — The order of the circuit court is affirmed.