Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

an advanced ORDER BY problem

KnackeredKnackered Member Posts: 1
Hi,

I'm programming in MySQL and PHP.

This seemed like quite a simple problem to me at first, but suddenly it seems a few steps beyond my current abilities.

I'm wanting to have a search statement which pulls out records in order of the 'region' field in my database. Now that's easy enough. But the way I want to order is is having for example 'Bristol' first.
(also it won't always be bristol, so it doesn't help that it's near the start of the alphabet. The region which I want to appear first is a variable).

Any help would be greatly appreciated

Comments

  • daviestrachandaviestrachan Member Posts: 26
    Hi
    Try
    SELECT `counties`.`county`, `counties`.`town`
    FROM `counties` ORDER BY county IN ('Cornwall','Lancashire') desc
    Regards
    Davie
    : Hi,
    :
    : I'm programming in MySQL and PHP.
    :
    : This seemed like quite a simple problem to me at first, but suddenly it seems a few steps beyond my current abilities.
    :
    : I'm wanting to have a search statement which pulls out records in order of the 'region' field in my database. Now that's easy enough. But the way I want to order is is having for example 'Bristol' first.
    : (also it won't always be bristol, so it doesn't help that it's near the start of the alphabet. The region which I want to appear first is a variable).
    :
    : Any help would be greatly appreciated
    :

Sign In or Register to comment.