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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:52:37+00:00 2026-05-29T05:52:37+00:00

I have a MySQL table ( tbl_filters ) with 3 columns: id , cat

  • 0

I have a MySQL table (tbl_filters) with 3 columns: id, cat, val

id & val are numeric, cat is varchar. There are multiple rows for each id.

I also have another table (tbl_info) with multiple columns, including an id which corresponds to the id from tbl_filters. There is a column called name, which is what I’m looking for.

I would like to select the name of all the rows which match a set value for cat, but only if the val for cat is the maximum for this id, and only if it is above a minimum set val.

In pseudocode it would be something like:

SELECT tbl_info.name FROM tbl_info,tbl_filters
WHERE (tbl_info.id=tbl_filters.id) AND (cat="mycat") AND (val>=0.3)
AND (there are no other rows for this id in tbl_info with a higher value for val)

Example:

tbl_filters
id,cat,val
1 eg1 0.43
1 eg2 0.60
1 eg3 0.78

tbl_info
id name
1 MyName

In the above example, a value should only be returned if I am looking for the cat called eg3, since that has the highest value. For the other cats, nothing should be returned, since they are not the highest value.

Another option would be to make a column in tbl_info just for the cat with the highest value, but that is a messy solution I would prefer to avoid.

  • 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-05-29T05:52:39+00:00Added an answer on May 29, 2026 at 5:52 am

    I THINK I’m following you… The INNER-MOST query pre-qualifies the HIGHEST Value per ID of your minimum value qualification, and the category that qualifies. ONCE you get that list, re-join back to get the name from the tbl_info. I’ve re-joined to the tbl_filters a second time in case there were other elements on that record you want, such as the date of the rate, or other things. If you DONT need that, you can ignore the second “tf2” join and just change the fields list from tf2.val to PreQualified.HighestQualVal.

    select
          ti.id,
          ti.name,
          tf2.val
       from
          ( select 
                  tf.id,
                  max( tf.val ) as HighestQualVal
               from
                  tbl_filters tf
               where
                      tf.cat = "mycat"
                  and tf.val >= 0.3
          ) PreQualified
    
          JOIN tbl_info ti
             on PreQualified.id = ti.id
    
          JOIN tbl_filters tf2
             on PreQualified.id = tf2.id
             AND PreQualified.HighestQualVal = tf2.val
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL table with approximately 3000 rows per user. One of the
I have a large MySQL table (about 750 million rows) and I just want
I have a table with several hundred million rows. One of the columns is
I have mysql table that has a column that stores xml as a string.
I have a MySQL table containing domain names: +----+---------------+ | id | domain |
I have a MySQL table LOGIN_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION
I have a mysql table that relies on the unix epoch time stamp equivalent
I have a MySQL table consisting of: CREATE TABLE `url_list` ( `id` int(10) unsigned
I have a MySQL table that will only have one row. What should my
I have a MySQL table with utf8 general ci collation. In the table, I

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.