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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:56:36+00:00 2026-05-10T15:56:36+00:00

The original query looks like this (MySQL): SELECT * FROM books WHERE title LIKE

  • 0

The original query looks like this (MySQL):

SELECT *  FROM books  WHERE title LIKE '%text%' OR description LIKE '%text%'  ORDER BY date 

Would it be possible to rewrite it (without unions or procedures), so that result will look like this:

  • list of books where title matches query ordered by date, followed by:
  • list of books where description matches query ordered by date

So basically just give a higher priority to matching titles over descriptions.

  • 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. 2026-05-10T15:56:36+00:00Added an answer on May 10, 2026 at 3:56 pm

    In sql server I would do the following:

    select * from books  where title like '%text%' or description like '%text%' order by case when title like '%text%' then 1 else 2 end, date 

    I’m not sure if you can include columns in ORDER BY in mysql that aren’t in the SELECT, but that’s the principle I’d use. Otherwise, just include the derived column in the SELECT as well.

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

Sidebar

Related Questions

Original SQL query is this; SELECT id,post_title,post_date FROM wp_posts where id='1' When I retrieve
I have a query whose code looks like this: SELECT DocumentID, ComplexSubquery1 ... ComplexSubquery5
I have a query that looks something like SELECT to_number FROM sent_texts WHERE to_number
Suppose we got a original query as follows: SELECT A, B, C FROM tblA
I have problems with a query in NHibernate. The original SQL query looks like
In MySQL the table test looks like this: id name lft rgt 1 Folder
I asked this question last week on SO- SQL Exclusion Query It looks like
I have a query which contains in the select clause: d1.id, d1.title, d1.original_doc, d2.id,
original column is like: 0.45::rafas::4.0::0.0::0.9 0.35::rasaf::4.0::110.0::1.0 and i would like to break the string
My autocomplete results for each item looks something like this: <h3>Celebrity Sweepstakes</h3><p>0 episodes</p> But

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.