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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:03:58+00:00 2026-05-20T14:03:58+00:00

Use: The user searches for a partial postcode such as ‘RG20’ which should then

  • 0

Use:
The user searches for a partial postcode such as ‘RG20’ which should then be displayed in a specific order. The query uses the MATCH AGAINST method in boolean mode where an example of the postcode in the database would be ‘RG20 7TT’ so it is able to find it.
At the same time it also matches against a list of other postcodes which are in it’s radius (which is a separate query).

I can’t seem to find a way to order by a partial match, e.g.:

ORDER BY FIELD(postcode, 'RG20', 'RG14', 'RG18','RG17','RG28','OX12','OX11') 
      DESC, city DESC

Because it’s not specifically looking for RG20 7TT, I don’t think it can make a partial match.

I have tried SUBSTR (postcode, -4) and looked into left and right, but I haven’t had any success using ‘by field’ and could not find another route…
Sorry this is a bit long winded, but I’m in a bit of a bind.
A UK postcode splits into 2 parts, the last section always being 3 characters and within my database there is a space between the two if that helps at all.

Although there is a DESC after the postcodes, I do need them to display in THAT particular order (RG20, RG14 then RG18 etc..) I’m unsure if specifying descending will remove the ordering or not

  • 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-20T14:03:59+00:00Added an answer on May 20, 2026 at 2:03 pm

    You’re on the right track, trimming the field down to its first four characters:

    ORDER BY FIELD(LEFT(postcode, 4), 'RG20', 'RG14', ...),
    --          or SUBSTRING(postcode FROM 1 FOR 4)
    --          or SUBSTR(postcode, 1, 4)
    

    Here you don’t want DESC.

    (If your result set contains postcodes whose prefixes do not appear in your FIELD() ordering list, you’ll have a bit more work to do, since those records will otherwise appear before any explicitly ordered records you specify. Before ‘RG20’ in the example above.)

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

Sidebar

Related Questions

Instead of hardcoding the default @author template I would like Eclipse to use user's
I use several user controls, along with standard ASP.Net controls, to build my webform.
This might be a silly question: Does HTTP ever use the User Datagram Protocol?
I want to use an existing user and user group table that the forums
I am a heavy command line user and use the find command extensively in
I have built a simple Eclipse plugin where a user may use a TableViewer
Are use cases just multiple user stories?? What are the benefits of using user
I want to use input from a user as a regex pattern for a
Can I use SQL Authentication with User Instances?
We're planning to use standard ASP.NET user authentication for our application. However, by default

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.