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
https://forums.phpfreaks.com/topic/244909-sorting-mysql-results-by-a-given-prefix/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.