Action to foreclose a mechanic’s lien. A demurrer to the complaint upon the ground that it did not state facts sufficient to constitute a cause of action was sustained, and plaintiff appeals. The lien is sought to be imposed upon the building only, and for materials that entered into its construction. The defendant is the vendee of the party by whom the building was erected. No personal judgment is claimed, or, under the complaint, could be recovered, in this case, against any one. Unless the complaint entitles plaintiff to the foreclosure of the lien claimed, it cannot be sustained for any purpose. To entitle a party to a lien for materials furnished to be used in the construction of a building, such materials must be furnished pursuant to a contract with the owner of the land upon which the building is situate. Such is the clear requirement of section 4788, Rev. Codes. The complaint in this case alleges that at the time such materials were furnished the *488state of North Dakota was, and ever since has been, the owner in fee of the land upon which the building is situated. No contract with the state is claimed, but it is alleged that the contract was made with one Haynes, defendant’s vendor of the building. It is claimed that the complaint sufficiently shows that the building was erected for the immediate use and benefit of said Haynes, and that by reason of that fact, and for the purpose of the mechanic’s lien law, he was the “owner” of the land, under section 4798, Rev. Codes. This section is identical with section 5483, Comp. Laws. In the case of Mahon v. Surerus, 9 N. D. 17, 81 N. W. Rep. 64, this court construed the latter section, and held that a contract made with one who had a homestead filing upon land would support a lien upon the building for materials used by such party in the construction of a house upon said land for his own use, notwithstanding the fact that under section 2296, Rev. St. U. S., the land could not be subjected to or sold under any such lien. This holding was based upon the fact that under section 5480, Comp. Laws, the plaintiff might, in every case, enforce his lien against the building without selling any interest whatever in the land upon which it stood. That feature of the statute as it appeared in the Compiled Laws has been materially changed by the statute- as it appears in the Revised Codes. It is true that the language giving the lien as found in section 4788, Rev. Codes, is the same as the former law, and declares that the party shall bave “a lien upon such building, erection or improvement and upon the land belonging to such owner on which the same is situated.” In Mahon v. Surerus we held that this language imported two separate liens, one upon the building and one upon the land. We so held because, as stated, under section 5480, Comp. Laws, the plaintiff could always enforce his lien upon the building alone, and remove it from the land. This cannot now be done. The buildings can now be sold and removed only under the conditions prescribed in sections 4794 and 4793, Rev. Codes. The first of these sections declares that the entire land upon which the building is situated “shall be subject to all liens created by this chapter to the extent of all right, title and interest owned therein by the owner thereof for whose immediate use or benefit such labor was done or things furnished, and when the interest owned in such land by such owner of such building, erection or other improvement is only a leasehold interest, the forfeiture of such lease for the nonpayment of rent or for noncompliance with any of the other stipulations therein shall not forfeit or impair such lien so far as it concerns such buildings, erections or improvements, but the same may be sold to satisfy such lien and be removed within thirty days after the sale thereof by the purchaser.” From this section it appears that, where materials are sold to one having a leasehold interest in land for the purpose of erecting a building upon such land, the lien for such materials must be enforced against the leasehold estate, including the building, which, as to the lienholder, becomes a part of the leasehold estate. But the lien cannot be defeated by a forfeiture of *489the leasehold interest, thus cutting off all estate in the land to which the lien could attach. In that event, and only in that event, the lien may be enforced against the building alone, and it may be removed from the land. Section 4793 provides that the liens for the things stated shall attach to the buildings or improvements in preference to any prior lien on the land, and, in order to give effect to this provision, it is declared that a court may, where there are prior incumbrances upon the land, direct that the building -alone be sold to satisfy the mechanic’s lien, and removed from the premises. It is only under these conditions that the buildings can be removed, and it is clear that in each the party erecting the building must have an interest or estate in the land that might be the subject of a judicial sale and transfer but for the conditions named in the statute. In all other cases the building «.must remain upon the land; but a lien upon a building that could in no manner be utilized would be so barren of benefits that we cannot presume the legislature ever intended to confer it. As the law now stands in this state, no mechanic’s lien can attach to the building or the land unless the party for- whose immediate use and benefit the building is erected has some estate or interest in the land. Our- present statute would, perhaps, be more symmetrical if section 5483, Com. Laws, — being section 4798, Rev. Codes, — had been changed to conform to other changes made. We cannot conceive that it was ever intended to permit a trespasser upon land, by erecting a building thereon for his own “immediate use and benefit,” to charge the land with a lien for the value of the work and materials in the building. The complaint in this case contains no allegations showing that the party who purchased the materials and erected the building had any leasehold interest in the land upon which the building was placed, or that any such lease, if it existed,' had been forfeited for any reason. Nor is there any allegation that there were any existing liens upon the land when the materials were furnished for the building that was erected thereon. Hence plaintiff is not entitled to any separate sale of the building. That is, however, the specific relief that he asks, and certainly his complaint entitles him to no other. The demurrer was properly sustained. Affirmed.
(84 N. W. Rep. 349.) All concur.