SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    europe
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Diplay Mysql results in turn

    Hi,
    i am struggling to find a solution about how to form a specific select statement. I have a table with 3 columns and the values bellow:

    Code:
    id  |  name   |  gender
    --------------------------
     1 |  John    |   M
     2 |  Andrew  |   M
     3 |  Peter   |   M
     4 |  Kim     |   W
     5 |  Mary    |   W
     6 |  Tim     |   M
    I wish to select them in a way that after a Male (M) comes a Girl (W) and then again a Male (M) etc and then, when there are no other W the remaining data in any order ... something like: John (M), Kim(W), Andrew(M), Mary(W), Peter (M), Tim(M). I know i could load them via php into a table and do this, but the db table is huge and this would take up proccess time.

    Is there a way to do this in pure MySQL as Select statement?

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    europe
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, i never thought this is that difficult


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •