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 8453109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:41:01+00:00 2026-06-10T11:41:01+00:00

I have a search form (running MySQL 5.0.88 ) to drill down through a

  • 0

I have a search form (running MySQL 5.0.88) to drill down through a product table. The search is a 2-step search. First run gets the number of results, 2nd run gets the data of records x-y.

I’m displaying min/max prices across all records by default and now want to update the min/max values based on the query results. I was thinking the best way to do this is inside the inital query, that gets the number of records.

Currently it looks like this:

SELECT  COUNT( a.id ) AS recordcount
        , a.nos
        , a.nos_anzeige

FROM artikelstammdaten a

WHERE 
        a.iln != "1111111111111" AND a.iln != "2222222222222" AND a.iln != "7777777777777"
    AND a.aktiv = "ja"
    AND a.artikelnummer LIKE '%name%' 
AND (a.modus = "OPEN" 
        OR a.iln IN ( 55555555555,66666666666,2222222222222 ) 
        )

GROUP BY a.iln, a.artikelnummer, a.preis_aktuell, a.artikelbezeichnung
HAVING (( sum(a.bestand) != 0 ) OR (a.nos = "ja" AND a.anzeige  = "ja" ))

Which gives me all matching records.

Problem:
Actually I only want the number of records (~ query.recordcount ) in a single record and not the individual records one by one (my attempt with COUNT doesn’t work). Something like this:

  totalrecords    min-price   max-price
  12345           9.99        1.204

where I can try to select min/max values across the resultset.

Question:
How do I have to modify my query, so I’m only getting the totalrecords (and can try to add min/max values)?

THANKS!

** EDIT: **
My table looks like this:

 CREATE TABLE dummy (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`iln` VARCHAR(13) NULL DEFAULT NULL,
`ean` VARCHAR(35) NULL DEFAULT NULL,
`artikelnummer` VARCHAR(35) NULL DEFAULT NULL,
`preis_ek` DECIMAL(12,2) NULL DEFAULT NULL,
`preis_vk` DECIMAL(12,2) NULL DEFAULT NULL,
`firma` VARCHAR(35) NULL DEFAULT NULL,
`nos` VARCHAR(4) NULL DEFAULT NULL,
`nos_anzeige` VARCHAR(4) NULL DEFAULT NULL,
`aktiv` VARCHAR(4) NULL DEFAULT NULL,
`modus` VARCHAR(4) NULL DEFAULT NULL,
`bestand` DECIMAL(10,0) NULL DEFAULT '0'
 )  

Prices would be preis_ek and preis_vk where I’m looking for min/max for each. THANKS!

EDIT:
Running the query like it is gives me a resultset like this:

"id"    "nos"   "nos_anzeige"   "MIN(a.preis_ek)"
"1153837"   "nein"  "nein"  "25,10"
"1153797"   "nein"  "nein"  "12,40"
....

which picks the min per record not across the resultset, if I’m not mistaken

  • 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-10T11:41:02+00:00Added an answer on June 10, 2026 at 11:41 am

    You can use

        SELECT count(recordcount), 
           Max(max_price), 
           Min(min_price) 
           FROM   (SELECT Count(a.id)   AS recordcount, 
                   a.nos, 
                   a.nos_anzeige, 
                   Max(preis_ek) AS max_price, 
                   Min(preis_ek) AS min_price 
            FROM   artikelstammdaten a 
            WHERE  a.iln != "1111111111111" 
                   AND a.iln != "2222222222222" 
                   AND a.iln != "7777777777777" 
                   AND a.aktiv = "ja" 
                   AND a.artikelnummer LIKE '%name%' 
                   AND ( a.modus = "open" 
                          OR a.iln IN ( 55555555555, 66666666666, 2222222222222 ) ) 
            GROUP  BY a.iln, 
                      a.artikelnummer, 
                      a.preis_aktuell, 
                      a.artikelbezeichnung 
            HAVING ( ( Sum(a.bestand) != 0 ) 
                      OR ( a.nos = "ja" 
                           AND a.anzeige = "ja" ) )) temp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a search form. I would like when someone type the term, first
I have a search form with min and max fields. It queries a MySQL
(Using MySQL and PHP) I have a search form that will allow my users
I have a simple JSF application, a search form and results table, and a
I have cgi script pulling search terms from an HTML form through CGI::Ajax .
I'm running coldfusion8/MySQL5.0.88 and I have a product search for which I need to
I have a search form where user can search for products within their specified
I have a search form on my site that submits the url in the
I'm a RoR beginner and am using Rails 3.2.3. I have a search form
I have a simple search form with a box and a button. <form action

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.