
27 Cal.2d 840 (1946)
HARRY A. LORD, Appellant,
v.
GORDON H. GARLAND, as Director of the Motor Vehicle Department, etc., et al., Respondents.
L. A. No. 18931. 
Supreme Court of California. In Bank.  
Apr. 2, 1946.
 Warren E. Libby for Appellant.
 Robert W. Kenny, Attorney General, and Frank Richards, Deputy Attorney General, for Respondent.
 EDMONDS, J.
 Soon after the Caravan Act (Stats. 1937, p. 2253; Deering's Gen. Laws, 1937, Act 5136) went into effect, Harry A. Lord sued to enjoin the director and other officers of the Motor Vehicle Department from enforcing its provisions as to him. While that suit was pending, he brought the present action "for declaratory relief, injunction and recovery of deposit." The director and the registrar of the *844 Motor Vehicle Department then in office were named as defendants. Their demurrer to the complaint was sustained without leave to amend, and the principal question presented upon Lord's appeal from the judgment subsequently entered concerns the plea of abatement relied upon by the respondents as justification for the dismissal of the action.
 The Caravan Act imposes a fee of $15 upon each automobile driven upon the state highways under specified circumstances. Pursuant to a stipulation in the first suit and an order of the court based thereon, Lord paid to the Motor Vehicle Department the fees imposed by the statute upon the condition that, if the statute should finally be declared unconstitutional in that action or otherwise, the amount deposited should be returned to him, but in the event of a contrary determination, the department might retain the fund, which now amounts to over $88,000. As the suit was not brought to trial within five years, it was dismissed upon that ground (Code of Civ. Proc.,  583), and the judgment has become final. (Lord v. Ingels, 64 Cal.App.2d 559 [149 P.2d 72].)
 The present action was filed during the pendency of the appeal in the first suit. The complaint is in three counts. The first is for a declaration of the rights of the parties to the money deposited under the stipulation and order in the prior litigation, a determination of the constitutionality of the Caravan Act, and an order enjoining the state officials, as trustees, from disposing of the fund created pursuant to the stipulation prior to an adjudication upon the merits. More specifically, it is alleged that, for more than seven years, Lord has been, and at the time of the filing of the complaint was, engaged in the business of caravaning automobiles from various eastern states into California. The vehicles so caravaned are owned by dealers and distributors doing business in California. Lord acts as the transporter for these distributors and dealers and is paid by them a flat price, which includes all taxes and license fees levied, and his net compensation for the caravaning depends upon the amount of taxes required to be paid.
 Other allegations of this count are that it is a suit in equity to enjoin the enforcement of the Caravan Act, which statute violates specified sections of the state and of the federal Constitution. The caravaner's responsibility for a vehicle brought into the state ceases upon delivery to the distributor *845 or dealer who owns it. Lord has been advised by the director and registrar of the Motor Vehicle Department that they will enforce the provisions of the Caravan Act and that he will have to pay the taxes required by the statute.
 The complaint then pleads the commencement of the former action and the issuance of the preliminary injunction by which the enforcement of the statute was stayed. The text of the stipulation in that action, and also of the order based upon it which authorized the deposit of fees in lieu of a bond, is included in the facts stated by Lord.
 When the prior action was dismissed, the complaint continues, the order made no provision for the disposition of the special fund which amounts to $88,282.50, but the court expressly reserved continuing jurisdiction until the final disposition of the money. In the former suit no determination was made in regard to the constitutionality of the statute, and although the special fund is subject to the jurisdiction and order of the court, the officers of the Motor Vehicle Department, notwithstanding the unconstitutionality of the Caravan Act, threaten to transfer the money on deposit and apply it to the payment of taxes as soon as the judgment of dismissal in the former action becomes final, which will be prior to any adjudication upon the question of constitutionality and contrary to the provisions of the order and stipulation.
 Lord also pleads in this count that because of the claim to the money on deposit, an actual controversy exists between him and the state officers relating to the legal rights and duties of the respective parties. The proper interpretation of the stipulation and of the order made thereon, he asserts, is that the special fund must be maintained inviolate pending the determination of the rights of the parties in this action. Under these circumstances, he concludes, the court should grant declaratory relief as to the rights of the parties, make its decision upon the question of the constitutionality of the statute under the second cause of action of the complaint, and render judgment for the disposition of the deposit accordingly.
 The second count of the complaint includes, by reference, the prior allegations relating to the manner in which Lord conducts his business and the requirement of the officers of the Motor Vehicle Department that he pay the fees fixed by *846 the statute. It is also alleged that the Caravan Act is unconstitutional upon certain grounds specifically enumerated in the first count.
 In more detail, Lord pleads that the Caravan Act levies a tax upon each and every automobile driven upon any highway of the State of California for the purpose of offering it for sale and excepts from the operation of the law each automobile transported wholly within certain zones. All of the caravaning from eastern states done by Lord in California is exclusively within a single zone as defined by the act, although occasionally he caravans between two zones as defined in the statute and from points within the state to points outside of California. The officers charged with the enforcement of the legislation have informed Lord that they will continue to require of him a special permit as to each and all of the vehicles which he shall in the future caravan into the state. There is no provision of law whereby he may recover from these officers, or from the state, any sum or sums paid or to be paid. He has no plain, speedy or adequate remedy at law, this count concludes, and unless the court enjoins the enforcement of the statute, he will suffer irreparable damage.
 The third count pleads, by reference, all of the allegations of the first count, except those dealing with the controversy concerning the stipulation and order. The relief asked in this count is for judgment in the amount of $88,282.50.
 The respondents demurred "to the whole complaint," pleading "that there is another action pending between the same parties for the same cause," and that several causes of action are improperly united, namely, those stated in counts one and two of the complaint. As additional grounds for demurrer, they allege that the first and third counts state insufficient facts to constitute a cause of action, and that the second count is ambiguous, unintelligible, and uncertain.
 The record does not indicate the basis for the ruling of the trial court sustaining the demurrer without leave to amend, or that any ground for demurrer was abandoned. In support of his contention that the order was improper, the appellant argues that although the plea in abatement was directed to the "whole complaint," it is not well taken against count two as the allegations concerning the prior suit appear only in counts one and three; that the litigation first commenced *847 did not involve the identical parties and causes of action, and as the demurrer upon the ground of the prior action was directed to the entire pleading, without specifying any particular count, it is not sustainable against at least two of the causes of action, it should have been overruled. Concerning the charge that the first and second counts of the complaint are improperly united, Lord justifies their inclusion in the same complaint upon the ground that by each of them he seeks equitable relief in regard to "Claims arising out of the same transaction, or transactions connected with the same subject of action" as allowed by section 427, subdivision 8, of the Code of Civil Procedure.
 The general demurrer to the first cause of action, according to Lord, was argued only upon the erroneous premise that declaratory relief cannot be had against the state, and that directed to the third cause of action should also have been overruled, he insists, for the sole objection urged against it was that, as it differs only from the first cause of action in the relief asked, it is subject to the same ruling made upon the first count. Finally, says Lord, upon any ground, the demurrer should not have been sustained without leave to amend, and assuming that the trial court did not err in its determination concerning the plea in abatement, it should have limited its ruling to an interlocutory judgment suspending the action until final determination of the prior cause.
 Considering the demurrer to the complaint as a whole, the respondents take the position that Lord is now suing upon the same facts to obtain the same relief which he asked in the prior litigation against the same parties. The same controversy is the basis of the present action, according to the attorney general. Before final judgment in the first action, any further litigation was unnecessary and vexatious; now, Lord may bring a new action attacking the constitutionality of the Caravan Act. Also, in support of the judgment, the respondents maintain that because, in the first suit brought by Lord, the court eventually must order a disposition of the money held by the Motor Vehicle Department, the general demurrer to the first cause of action was properly sustained without leave to amend. The facts alleged in that count, the argument continues, do not show a legal obligation arising under the circumstances specified in section 1060 of the Code of Civil Procedure, hence there is no justiciable dispute between the parties. *848
 Turning to the second cause of action, Clark v. Gray, 306 U.S. 583 [59 S.Ct. 744, 83 L.Ed. 1001], in which the constitutionality of the Caravan Act was upheld, is relied upon to support the ruling of the trial court. The last count of the complaint is said to have the same infirmities as the first cause of action. The respondents argue that at the time the demurrer was sustained, Lord was attacking the stipulation and order in a case which was then pending, and so far as the disposition of the money is concerned, neither count states a cause of action. Finally, the causes of action now separately stated are not of the kind which may be joined under any provision of section 427 of the Code of Civil Procedure.
 [1] Under section 430 of the Code of Civil Procedure the pendency of another action between the same parties for the same cause is made a ground for demurrer. The plea is dilatory in its nature and is not favored. It may be made only when the face of the complaint shows that the causes of action and the issues in the two suits are substantially the same. (Knapp v. Knapp, 15 Cal.2d 237, 243 [100 P.2d 759]; O'Hara v. Grand Lodge I.O.G.T., 213 Cal. 131, 144 [2 P.2d 21]; Conner v. Bank of Bakersfield, 173 Cal. 400, 402 [163 P. 353]; National Auto. Ins. Co. v. Winter, 58 Cal.App.2d 11, 16 [136 P.2d 22]; Burnan v. Irigoyen, 56 Cal.App.2d 624, 631 [133 P.2d 3]; Warner v. Roadshow Attractions Co., 56 Cal.App.2d 1, 7 [132 P.2d 35].) [2a] Where, for all that appears in the complaint, the prior suit does not involve the entire cause of action presented by the complaint in the later litigation, the plea of abatement should be raised by answer rather than by demurrer. (Conner v. Bank of Bakersfield, supra, p. 403; National Auto. Ins. Co. v. Winter, supra, p. 16.)
 [3] As a test for determining whether the causes of action are the same or different, it is the universal rule that a plea in abatement may be maintained only where the claim sued upon in the second action is such that a final judgment in the first one could be pleaded in bar as a former adjudication. (Baker v. Eilers Music Co., 175 Cal. 652, 655 [166 P. 1006]; McCormick v. Gross, 135 Cal. 302, 305 [67 P. 766].) "While it is true that as a general rule a judgment is a bar as res judicata not only as to a subsequent action on the same matter actually determined, but also as to all issues that might have been litigated as incident to or essentially connected with the subject matter of the litigation *849 and every matter coming within its legitimate purview ..., it is also true that that only is adjudged in a former judgment which appears upon its face to have been adjudged or which was actually and necessarily included therein or necessary thereto. ... And when it affirmatively appears that an issue was not determined by the judgment, it obviously is not res judicata upon that issue." (Stark v. Coker, 20 Cal.2d 839, 842 [129 P.2d 390].) Other recognized exceptions to this rule "include a situation wherein it has appeared that the questioned issue in the subsequent action was neither germane to nor necessarily connected with the actual issues that were raised in the former action, even though, with propriety such issues might have been presented therein. ... Nor is the rule applicable to rights, claims or demands, although growing out of the same subject matter, but which constitute separate or distinct causes of action, and which were not put in issue in the former action." (Title Guarantee & Trust Co. v. Monson, 11 Cal.2d 621, 631 [81 P.2d 944]; see, also, City of San Diego v. California Water & Tel. Co., 71 Cal.App.2d 261, 276 [162 P.2d 684].)
 [4] And the rule of res judicata extends only to the facts and conditions as they existed at the time the judgment was rendered, or more correctly speaking, at the time the issues in the first action were made, and to the legal rights and relations of the parties as fixed by the facts determined by that judgment. When other facts or conditions intervene before the second suit, furnishing a new basis for the claims and defenses of the respective parties, the issues are no longer the same and the former judgment cannot be pleaded in bar of the second action. (Bank of America etc. Assn. v. McLaughlin, 22 Cal.App.2d 411, 415 [71 P.2d 291, 72 P.2d 554].)
 [2b] Applying the foregoing rules to Lord's complaint in the present case, it does not appear upon the face of that pleading whether all matters now sued upon were adjudged in the former action, nor whether such matters were actually and necessarily included therein or necessary thereto. Neither does it appear whether other facts or conditions intervened before the commencement of the second suit. For these reasons, at least, the objection upon the ground of another action pending should have been raised by answer rather than by demurrer. [5] Also, the demurrer to the entire complaint that another action was pending is not applicable to the second count of the complaint which makes no reference *850 to the former action. [6, 7] In ruling upon a demurrer, the averments of one count cannot be amplified by the allegations of another separately stated cause of action in the same pleading unless the latter are included by special reference or otherwise in the portion of the complaint under attack (see Hopkins v. Contra Costa County, 106 Cal. 566, 570 [39 P. 933]; Bidwell v. Babcock, 87 Cal. 29, 33 [25 P. 752]; Baldwin v. Ellis, 68 Cal. 495, 496 [9 P. 652]; Haskell v. Haskell, 54 Cal. 262, 265), and a demurrer which attacks an entire pleading should be overruled if one of the counts therein is not vulnerable to the objection. (Brandt v. Brandt, 178 Cal. 548, 550 [174 P. 55]; Jensen v. Dorr, 159 Cal. 742, 745 [116 P. 553]; Armstrong v. Adams, 102 Cal.App. 677, 681 [283 P. 871]; Wakeman v. Green, 98 Cal.App. 50, 52 [276 P. 387].)
 [8a] But assuming that the ruling upon this point was correct, the court should not have denied leave to amend. The judgment dismissing the prior action for want of prosecution is not one upon the merits (Superior Oil Co. v. Superior Court, 6 Cal.2d 113 [56 P.2d 950]; Bell v. Solomons, 162 Cal. 105 [121 P. 337]; Matteson v. Klump, 100 Cal.App. 64 [279 P. 669]) and it does not bar a subsequent action upon the same cause. (Gonsalves v. Bank of America, 16 Cal.2d 169 [105 P.2d 118]; Goddard v. Security Title Ins. & Guar. Co., 14 Cal.2d 47 [92 P.2d 804].) Section 597 of the Code of Civil Procedure, as amended in 1939, provides that when an answer pleads a prior action pending, or any other defense constituting a ground of abatement, such special defense shall first be heard, "and where the defense of another action pending is sustained (and no other special defense is sustained) an interlocutory judgment shall be entered in favor of the defendant pleading the same to the effect that no trial of other issues shall be had until the final determination of such other action, and the plaintiff may appeal from such interlocutory judgment. ..."
 [9] The word "answer," as used in the other sections of the Code of Civil Procedure, has been construed as broad enough to include a demurrer. For example, in Evans v. Superior Court, 14 Cal.App.2d 743 [59 P.2d 159], it was held that the provisions of section 581a, which authorize the dismissal of an action where no answer is filed and plaintiff fails to have judgment entered within three years after service of summons, must be construed as including a demurrer. The courts also concluded that the filing of a demurrer prevented the entry of a judgment when section 585 of the Code *851 of Civil Procedure provided that, if no answer had been filed within the time specified in the summons, the clerk must enter the defendant's default and immediately enter judgment for the amount demanded. (Fletcher v. Maginnis, 136 Cal. 362 [68 P. 1015]; Oliphant v. Whitney, 34 Cal. 26; Davidson v. Gresham, 25 Cal.App. 484 [144 P. 147].) [10] By analogy, at least, the word "answer" as used in section 597 of the Code of Civil Procedure is broad enough to include demurrer and an interlocutory judgment should also be entered where the plea in abatement is presented by demurrer. (See: 1 Cal.Jur. 37 and cases there collected.)
 [11] The purpose of the interlocutory judgment under circumstances such as are shown in the present case is to permit the trial court to retain jurisdiction over the subsequent action so that when a final determination is had in the prior pending action the court will be empowered to determine the issues in the subsequent suit. [12] If a judgment upon the merits is rendered in the suit first commenced, the party asserting the plea in abatement should be granted leave to amend to plead the res judicata effect of the judgment in bar of the subsequent action. [8b] But if, as in the present case, the prior litigation is not determined upon the merits, the trial court should hear and decide the rights of the parties in accordance with the issues presented by the pleadings in the second action.
 [13] The appellant relies upon a number of decisions which turned upon the defense of another action pending, but in none of them was a judgment of dismissal, which followed an order sustaining a demurrer without leave to amend, affirmed upon appeal. The only relief to which a litigant is entitled upon the plea, by either demurrer or answer, that a prior action between the same parties is pending and undetermined is the judgment specified by section 597, Code of Civil Procedure, that the second action abate. The order, if based upon that plea, was therefore erroneous and if none of the other grounds of demurrer justifies the ruling, it was an abuse of discretion to withhold leave to amend.
 [14] Considering the general demurrer to the first count from the standpoint of the sufficiency of the pleading to state a cause of action for declaratory relief under section 1060 of the Code of Civil Procedure, one invoking that remedy must allege facts from which the court may determine that an actual controversy relating to legal rights and duties of the respective parties exists. (City of Alturas v. Gloster, *852 16 Cal.2d 46, 48 [104 P.2d 810]; Frasch v. London & Lancashire F. Ins. Co., 213 Cal. 219, 225 [2 P.2d 147]; American Tel. & Tel. Co. v. California Bank, 59 Cal.App.2d 46, 51 [138 P.2d 49].) Lord's allegations comply with this requirement; they state a cause of action for such relief and would support a declaratory judgment. [15] The remedy however, may be refused in the discretion of the trial court if it appears that the determination is not necessary or proper at the time and under all the circumstances. (Code Civ. Proc.,  1061.) [16] Where the facts pleaded by the plaintiff would justify a trial court in applying that rule, it has been held that the court may sustain a general demurrer to the complaint. (Moss v. Moss, 20 Cal.2d 640, 642 [128 P.2d 526, 141 A.L.R. 1422]; Simpson v. Security First Nat. Bank, 71 Cal.App.2d 154, 158 [162 P.2d 494].) [17] However, it is equally true that section 1061 of the Code of Civil Procedure, which allows the trial court to refuse to render a declaratory judgment, does not apply where, upon the facts stated, the plaintiff is entitled to some relief in connection with the matter which occasioned the controversy. (Henderson v. Oroville-Wyandotte Irr. Dist., 207 Cal. 215 [277 P. 487]; Phelps v. Loop, 53 Cal.App.2d 541 [128 P.2d 63]; Zimmer v. Gorelink, 42 Cal.App.2d 440 [109 P.2d 34].)
 [18] As grounds for sustaining the general demurrer to the first count, the attorney general contends that the facts presented do not give rise to a present controversy and that section 1060 of the Code of Civil Procedure does not authorize the bringing of an action for declaratory relief against the state or its governmental agencies. However, considering all of the circumstances as they existed at the time the complaint was filed and in view of the fact that the action for declaratory relief may be invoked to test the constitutionality of a statute, the trial court would have abused its discretion if it had sustained the general demurrer to the first cause of action upon the ground that the remedy was not necessary or proper. [19] And, contrary to the statement of the attorney general, declaratory relief is an available remedy against the state. (Hoyt v. Board of Civil Service Commrs., 21 Cal.2d 399 [132 P.2d 804].)
 [20] However, Lord does not state a cause of action for injunctive relief in the first count because no facts are alleged tending to show that irreparable injury will result if the funds are converted by the respondents prior to an adjudication upon the issue of constitutionality. (McKay Jewelers *853 Inc. v. Bowron, 19 Cal.2d 595, 598 [122 P.2d 543, 139 A.L.R. 1188]; Sunset Scavenger Corp. v. Oddou, 11 Cal.App.2d 92, 98 [53 P.2d 188]; see: 14 Cal.Jur. 261.) Conceding that an injunction is ancillary to other relief sought, he has not pleaded any equitable grounds essential to the invocation of the remedy. (Sunset Scavenger Corp. v. Oddou, supra, p. 98.) [21] But where not all of a count is subject to demurrer, the objection must be directed to the particular portion of it which fails to meet the law's requirements, and a general demurrer to a count should be overruled if, upon any theory, it states a cause of action. (Johnson v. Clark, 7 Cal.2d 529, 536 [61 P.2d 767].)
 [22] In count two Lord seeks injunctive relief against the enforcement of the Caravan Act upon the ground of asserted unconstitutionality. The Supreme Court of the United States has upheld the Caravan Act under the federal Constitution as written (Clark v. Gray, supra), but Lord alleges that the application of the statutory requirements to his particular method of doing business violates the provisions of the federal and also of the state Constitution. Unlike the first count, it is here alleged that there is no provision of law whereby the appellant may recover from the respondents or from the State of California any money paid to the Motor Vehicle Department as taxes. To this count of the complaint the respondents demurred only upon the ground that it is uncertain, ambiguous and unintelligible, in certain enumerated particulars.
 The attorney general recognizes the rule that a special demurrer should not be sustained without leave to amend if the deficiencies of a complaint can be corrected by amendment. But because of the decision in Clark v. Gray, supra, and for other reasons, he asserts, it is patent that Lord cannot amend the second count so as to present a good cause of action to test the constitutionality of the Caravan Act. The objections raised by special demurrer do not go to the failure to allege sufficient facts (Callahan v. Broderick, 124 Cal. 80, 83 [56 P. 782]; see: Bancroft's Code Pleading, vol. 1, p. 347) and as the allegations of Lord's complaint are sufficiently clear to apprise the defendants of the issues which they are to meet, the special demurrer should have been overruled. (People v. Lim, 18 Cal.2d 872, 882 [118 P.2d 472]; Jacobson v. Oakland Meat etc. Co., 161 Cal. 425, 433 [119 P. 653, Ann.Cas. 1913B 1194].)
 [23] As the third count of the complaint is for a money *854 judgment and is grounded upon the facts pleaded in the first count, which states a cause of action, the demurrer to it was not well taken.
 [24] Concerning other aspects of the complaint, the demurrer upon the ground that several causes of action have been improperly united is based upon the proposition that the first and second counts do not arise out of the same transaction or transactions connected with the subject of the action (Code Civ. Proc.,  427.) But certainly every transaction of the plaintiff, including the stipulation and order thereon, is connected with the constitutionality of the Caravan Act; and the validity of that statute is the question principally at issue in each count of the complaint. (See: Carter v. Turner, 90 Cal.App. 193 [265 P. 870]; Blodgett v. Trumbull, 83 Cal.App. 566 [257 P. 199]; Boulden v. Thompson, 21 Cal.App. 279 [131 P. 765].)
 [25] Moreover, a demurrer upon the ground of improper joinder of causes of action in the same complaint should not be sustained without leave to amend when it appears that the defect can be cured by amendment. (See: Ehlen v. Burrows, 51 Cal.App.2d 141, 144 [124 P.2d 82]; 21 Cal.Jur. 119-122.)
 It should be kept clearly in mind that at the time of the filing of the plea of another action pending and the ruling upon it, the appeal from the judgment dismissing the suit first commenced had not been decided. Although that judgment has now been affirmed, the order sustaining the demurrer to the complaint in the present litigation must be considered in the light of the circumstances as they existed at the time the plea was filed. However, if the state officials hereafter object to the further prosecution of the present action upon the ground that the first suit is still pending for a limited purpose, the question will arise whether the motion now pending in Lord v. Superior Court (see post, p. 855 [168 P.2d 14]), for an order disposing of the fund allows the trial of issues sufficiently broad to justify a further plea in abatement.
 The judgment is reversed with directions to the trial court to overrule the demurrer and to allow the respondents to answer.
 Gibson, C.J., Shenk, J., Carter, J., Traynor, J., Schauer, J., and Spence, J., concurred.
