Jump to content

Sorting MySQL results by a given prefix


j.smith1981

Recommended Posts

I am sorry if this has been covered before just the examples given are way more complex than what I need really.

 

I was wondering how I would go about sorting the following list here (as it's displaying at this very moment):

 

Original Product 1

Original Product 2

Compatible Product 1

Compatible Product 2

 

I would like (or need rather) the products to be displayed like so:

 

Original Product 1

Compatible Product 1

Original Product 2

Compatible Product 2

 

(essentially the Original appears first for that given product and then the comparitive Compatible, I am dealing with Printer Cartridges here, but this should be enough of an example to illustrate what I am aiming for).

 

How would the ORDER BY clause look, I mean I know it's a substr on the first space, just not exactly sure about how to go about getting this clause working, tried a few times but it fails each time.

 

Any helps massively appreciated!

 

Jeremy.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.