The action is to foreclose an overdue mortgage for $9,000. The defendant Schlanger demurs for misjoinder of causes of action and for general insufficiency. The allegations of the complaint affecting said defendant and numbered tenth and eleventh read as follows: “ Tenth. That the defendant Solomon Schlanger had on or about the Yth day of May, 1909, executed and delivered unto the plaintiff herein, an agreement in writing and sealed with his seal, dated on that day, wherein and whereby the said Solomon Schlanger did firmly and jointly bind himself, his heirs, executors and administrators in the sum of One thousand ($1,000) dollars to be paid unto the plaintiff herein, which agreement should be void if the defendant Samuel Leder, his heirs, executors, administrators or assigns shall pay or cause to be paid unto the plaintiff herein, the sum of nine thousand ($9,000) dollars, which was the remaining unpaid balance on the Yth day of May, 1909, on the bond and mortgage held by the plaintiff herein, together with the interest thereon at and after the rate of six (6%) per cent per annum.
“Eleventh. That by the said agreement all of the covenants and conditions contained in the mortgage was (sic) made a part thereof with like force and effect as if the same was specifically set forth at length in said agreement. That said bond and *126mortgage became due and payable on the 27th day of August, 1910.”
The demurrer is sought to be sustained by the argument. that no cause of action will lie against the demurrant except one at law, and then only after all the remedies against the principal debtor have been exhausted and there has been a failure to collect the full amount due. There can be no doubt that the bond given by the demurrant, as described in the complaint, was intended as and amounted to collateral security, to the extent of $1,000, for the payment of the principal debt. Section 1627, subdivision 1, of the Code of Civil Procedure makes provision for just such a case. It provides that: “ Any person who is liable to the plaintiff for the payment of the debt secured by the mortgage may be made a defendant in the action, and if he has appeared or has been personally served with the summons, the final judgment may award payment by him of the residue of the debt remaining unsatisfied, after a sale of the mortgaged property and the application of the proceeds pursuant to the directions contained therein.” The purpose of the provision of the Code was to dispose of the entire proceeding in one action so as to avoid a multiplicity of suits. (Robert v. Kidansky, 111 App. Div. 475; Equitable Life Ins. Society v. Stevens, 63 N. Y. 341; Scofield v. Doscher, 72 id. 491.) If plaintiff had failed to make Schlanger a party defendant, and waited to sue him at law after exhausting her remedy against the' principal debtor and the mortgaged property, she would have been unable to sue without first obtaining the leave of the court (Code Civ. Proc. § 1628; McKernan v. Robinson, 84 N. Y. 105), and might be refused such leave for the very reason that she had omitted to make Schlanger a party to the foreclosure action and had thus prevented him from protecting himself on the foreclosure sale. (See Darmstadt v. Manson, 144 App. Div. 249.) It is true that plaintiff erroneously asks in her prayer for relief for a separate judgment against Schlanger for the amount of his bond. What she is entitled to is a judgment for any deficiency, not exceeding $1,000, that there may be found to be after the plaintiff’s remedies upon the bond and mortgage are exhausted, but a merely erroneous prayer for relief does not condemn a complaint, if it states facts entitling the plain*127tiff to any relief at all, for the court will mould its judgment to fit the facts of the case and conserve the rights of the parties.
The order appealed from is right and must he affirmed, with ten dollars costs and disbursements.
Ingraham, P. J., and Clarke, J., concurred; McLaughlin and Dowling, JJ., dissented.