Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:58:37+00:00 2026-06-14T06:58:37+00:00

what I need (and got with temporary tables or views is this): numcasos valcount1

  • 0

what I need (and got with temporary tables or views is this):

numcasos  valcount1  valcount2  
--------  ---------  -----------
       0          2            1
       1          1            2
       2     (NULL)       (NULL)
       3     (NULL)            1
       4          1       (NULL)
       5     (NULL)       (NULL)
       6     (NULL)       (NULL)
       7     (NULL)       (NULL)
       8     (NULL)       (NULL)
       9     (NULL)       (NULL)
      10     (NULL)       (NULL)

This is an example because I need it for 300+ valcounts. MySQL:

CREATE TEMPORARY TABLE sumnum1
SELECT numos.num1 AS num1,
 COUNT(*)   AS valcount1      
FROM `numos` 
GROUP BY numos.num1  ; 

CREATE TEMPORARY TABLE sumnum2
SELECT numos.num2 AS num2,
 COUNT(*)   AS valcount2      
FROM `numos` 
GROUP BY numos.num2  ; 



SELECT casos.`numcasos` AS numcasos, 
sumnum1.valcount1 AS valcount1,
sumnum2.valcount2 AS valcount2

FROM ( casos
LEFT JOIN sumnum1
ON (casos.`numcasos`= sumnum1.num1)
LEFT JOIN sumnum2
ON (casos.numcasos = sumnum2.num2))

what I would like is to get the same result with subqueries instead but I get the error message:

Subquery returns more than 1 row

Is it possible in MySQL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:58:38+00:00Added an answer on June 14, 2026 at 6:58 am

    Try something like

    SELECT casos.numcasos AS numcasos, 
    sumnum1.valcount1 AS valcount1,
    sumnum2.valcount2 AS valcount2
    FROM casos
    LEFT JOIN
    (
        SELECT numos.num1 AS num1, COUNT(*) AS valcount1
        FROM numos GROUP BY numos.num1 
    )sumnum1  ON (casos.`numcasos`= sumnum1.num1)
    LEFT JOIN 
    (
       SELECT numos.num2 AS num2, COUNT(*) AS valcount2
       FROM numos GROUP BY numos.num2  
    )sumnum2 ON (casos.numcasos = sumnum2.num2))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is because the string is got from a ResultSet which returns no value
I just got to know about the global temporary tables(I use oracle as db)
I got 3 divs that: need to to be side by side ( in
i got some problem and need help .. my plan : 1. get ip
I've got a problem where I need to know about all the bindings that
I got a variable in a bash script that I need to replace. The
I've got some UITableViewCells that need to change their height depending on the length
Got a c#.net app which I need to modify. The query at the moment
I've got some HTML files that need to be parsed and cleaned, and they
I've got a button that I need to be disabled when validation errors occur

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.