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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:49:52+00:00 2026-06-07T11:49:52+00:00

I am writing a PHP/MYSQL search function which takes a users search query (as

  • 0

I am writing a PHP/MYSQL search function which takes a users search query (as a string) and matches it to records from a table by predefined fields and quantities (eg: bedrooms = 2, max_price < 100)

This is working fine, but now I want to order the results by a condition. So for example:

  • The users query is “2 Bedroom Penthouse”

  • The function matches records that have a value of 2 for the row
    bedrooms

I now want to keep the results that match, but order the results by the results that match for a description row with a value of “penthouse” (anywhere in the description string (which is a long string of lots of words))

I can match the results that have the word “penthouse” in the description, but what is the best way to order the results with the matched results first?

So, basically, how do you order results by another query?

  • 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-07T11:49:55+00:00Added an answer on June 7, 2026 at 11:49 am

    You don’t. You write a more complex ORDER BY clause.

    SELECT ...
      ORDER BY ..., description NOT LIKE "%penthouse%"
    

    (We invert the expression since false orders before true)

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

Sidebar

Related Questions

I am writing a php/mysql app that uses a few different tables. Table 1
I'm writing a multistore webshop application in PHP/MYSQL. The products table has about a
I am writing in PHP a mySQL query. I would like to duplicate a
I'm writing a basic message-script in PHP/MySQL but I'm stuck at a database query
I'm struggling with some PHP/MySQL code. I am reading from 1 table, changing some
I'm writing a php-mysql application. The application allows the user to run a search
I am writing a PHP and MySQL application in which i have to concatenate
i am writing a site from scratch using php/mysql and am using GET requests
I am writing a PHP application which uses MySQL in the backend. I am
I am writing a prototype auction/listings project in PHP (MySQL backend). I have a

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.