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

  • Home
  • SEARCH
  • 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 8815483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:23:26+00:00 2026-06-14T04:23:26+00:00

So, I am trying to modify the following query: SELECT * FROM flow INNER

  • 0

So, I am trying to modify the following query:

SELECT *
FROM flow
INNER JOIN flow_strings
    USING(node_id)
WHERE
    (
        flow.parent = 0
        OR flow.parent = :user_flow
    )
    AND flow.source = 0
    AND :input LIKE CONCAT('%', flow_strings.sql_regex, '%')
ORDER BY flow.parent DESC, RAND()

The query works exactly how it’s supposed to. HOWEVER, I need to modify it a bit. Assuming a priority INT column on table flow, how can I modify it to only grab results where flow.priority is equal to MAX(priority)?

In other words, I want the query to do exactly what it does, but in the event that there are priority values, I want it to only select from the highest priorities. If there is more than one high priority value, then it should select both.

I have seen some other posts on StackOverflow that appear to be asking the same question, but the answers don’t seem to explain the solution–they only post the answer. If you could attach an explanation of what’s going on, I’d hugely appreciate it! Thanks!

  • 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-14T04:23:27+00:00Added an answer on June 14, 2026 at 4:23 am

    One way to solve this is using a subquery:

    SELECT *
    FROM flow f
    INNER JOIN flow_strings
        USING(node_id)
    WHERE
        (
            f.parent = 0
            OR f.parent = :user_flow
        )
        AND f.source = 0
        AND :input LIKE CONCAT('%', flow_strings.sql_regex, '%')
        AND priority=(SELECT MAX(priority) FROM flow f2 where [grouping condition])
    ORDER BY flow.parent DESC, RAND()
    

    This way you select only rows with the biggest priority among those who satisfy the grouping condition. Generally this one is an equality between one or more fields from the main table and the corresponding fields in the subquery. For example in your case could be:

    f.parent=f2.parent
    

    (this is my guess, I don’t know exactly the meaning of your tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following plugin: http://codecanyon.net/item/dynamic-step-process-panels/118950 and I am trying to modify its
I'm trying to modify the following query to find the rank of a specific
My java app is trying to modify the following line from a file: static
I have the following SQL query: SELECT DISTINCT ProductNumber, PageNumber FROM table I am
I'm trying to modify a Jquery plugin to fix the bugs. Following are the
I am trying to modify an Integer field on existing table from nullable to
I am trying to modify the code below to check the input from a
I am trying to modify a table within a database, as follows: using (SqlCeCommand
I am trying to modify a user query in order to return an extra
I'm trying to modify the following rewrite conditions so that only strings that begin

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.