
131 N.W.2d 455 (1964)
David Lee WRIGHT, Appellant,
v.
John E. BENNETT, Warden, Appellee.
No. 51450.
Supreme Court of Iowa.
November 17, 1964.
David Lee Wright, pro se.
Evan Hultman, Atty. Gen. of Iowa, for appellee.
STUART, Justice.
David Lee Wright was tried and convicted of the crime of larceny of a motor vehicle. On March 6, 1963 he was sentenced to be confined at Fort Madison for the term of not to exceed 10 years. The mittimus provided "that this term run concurrently with a sentence entered in the District Court of Pottawattamie County at Avoca, Iowa on February 10, 1961 * * *". This sentence was also for a term of 10 years on a conviction of breaking and entering.
On January 27, 1964 he filed a petition for a writ of habeas corpus alleging that certain of his constitutional rights under the 6th and 14th amendments had been violated. The trial court denied the writ on the ground that the issues raised in this petition were in existence prior to and *456 should have been included in a petition filed October 31, 1963 which had been denied after hearing. Petitioner appealed and the State moved to dismiss the appeal because the petition showed on its face that it was directed solely to the March 6, 1963 conviction and sentence and failed to show or allege that the term of imprisonment on the Pottawattamie County conviction of February 10, 1961 had expired or was no longer in effect. The motion was ordered submitted with the appeal.
I. The motion to dismiss is sustained. Under this record it appears the petitioner is lawfully detained under the sentence imposed on the Pottawattamie County conviction. It has not been attacked.
"It is well settled that a prisoner has no right to a writ of habeas corpus unless he is entitled to immediate release." 39 C.J.S. Habeas Corpus § 13, p. 443.
A "writ of habeas corpus will not be granted to determine a mere abstract or moot question. The writ is available only where the release of the prisoner will follow as a result of a decision in his favor. It will be denied where it is apparent that the only result, if the writ were issued, would be the remanding of the petitioner to custody." 25 Am.Jur. 153. Habeas Corpus § 15.
The United States Supreme Court considered a similar question in McNally v. Hill, 293 U.S. 131, 55 S.Ct. 24, 79 L.Ed. 238, in which the petitioner attacked the validity of a conviction on the third count of an indictment while serving sentences on the first two counts. The sentence on the third count was to follow that on the first two counts. The court said:
"We conclude that, as it appears from the petition that the detention of the petitioner is lawful under the sentence on the second count, there is no occasion, in a habeas corpus proceeding, for inquiry into the validity of his conviction under the third." 293 U.S. p. 135, 55 S.Ct. p. 26, 79 L.Ed. p. 241.
"The purpose of the proceeding defined by the statute was to inquire into the legality of the detention, and the only judicial relief authorized was the discharge of the prisoner or his admission to bail, and that only if his detention were found to be unlawful. * * * There is no warrant in either the statute or the writ for its use to invoke judicial determination of questions which could not affect the lawfulness of the custody and detention, and no suggestion of such a use has been found in the commentaries on the English Common law". 293 U.S. 136, 55 S.Ct. 27, 79 L.Ed. 242.
No cases have been found in which we have passed upon this question directly. We have however held a prisoner cannot be discharged on habeas corpus on the ground that the sentence was excessive until he has served that part of the sentence which the court could legally impose. West v. Lainson, 235 Iowa 734, 17 N.W. 2d 411; Smith v. Hollowell, 209 Iowa 781, 229 N.W. 191. The situations are analogous.
II. The matters set forth in the petition upon which the prayer for a writ of habeas corpus is based were necessarily in existence when petitioner filed his previous petition on October 31, 1963. This case therefore falls within the rule announced in Alberts v. Lainson, 250 Iowa 748, 94 N.W.2d 94. A petitioner cannot split his cause of action and present his claim for writ of habeas corpus piecemeal.
The appeal is dismissed.
Appeal dismissed.
All Justices concur except HAYS, J., not sitting.
