SQL Query Q

Discussion in 'OT Technology' started by Sexual Vanilla, Nov 2, 2007.

  1. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
    I have a field that has 2 words in it, separated by a space. Is there a way to select * from the table, ordering alphabetically by the 2nd word in the field? I could create another field and just split the two words, but if there is a way to do it without revamping our existing structure, it would be great.
     
  2. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
    Never mind...found a way.

    If anyone is interested...

    Code:
    SELECT rtrim(Name, CHARINDEX(' ', Name)) as SECONDWORD
    from whatever
    where youranoob = 'gomer pile'
    order by SECONDWORD
    
     

Share This Page