Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    10

    Unanswered: match records by specific fields

    I wish to match each record in a subset of a table with a record in a subset of the same table w.r.t two specific fields, i.e age and handle:

    time name surname age occupation handle

    12:20 Sam Gamgee 27 liontamer grr
    12:21 Peter Postlewaite 52 dancer tippytap
    12:22 Simon Cowell 98 heckler blech
    .
    .
    .
    15:42 Hello Kitty 98 cat blech
    15:43 Roger Moore 27 lecherer grr
    15:43 Sammy Davis 52 artiste tippytap


    I'd like to order them as such:

    12:20 Sam Gamgee 27 liontamer grrr
    15:43 Roger Moore 27 lecherer grr
    12:21 Peter Postlewaite 52 dancer tippytap
    15:43 Sammy Davis 52 artiste tippytap
    12:22 Simon Cowell 98 heckler blech
    15:42 Hello Kitty 98 cat blech

    How do I make the select statement to group them as above? have tried using a query in a query, but the syntax is giving me issues...

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Fantastic sample data
    In a sense, you are not matching but ordering. Is that correct?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2009
    Posts
    10
    You are correct. In reality the records above are a resultset of another query - does this complicate issues?

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I don't know without more specifics.
    However, to get from your sample data to your required output you would simply need:
    Code:
    SELECT time, name, surname, age, occupation, handle
    FROM myTable
    ORDER BY age, handle
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2009
    Posts
    10
    That clears my thinking somewhat, works like a charm! I didn't understand the use of grouping. Now I do. Thanks!

Posting Permissions

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