ordering from another table

Discussion in 'PHP' started by promotingspace.net, Nov 7, 2008.

  1. #1
    Hi
    i have offers table that contain a field as the user_id
    and member table with the field "membertype" ( 1 , 2 or 3 )
    I want to list the offers ordered by user type (gold type's offers are shown first)
    solutions:
    1. adding the membertype field to offer table when posting an offer
    etc.
    do you think this is the best (easiest and fastest) way?
    thanks for your notes
     
    promotingspace.net, Nov 7, 2008 IP
  2. npsari

    npsari Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Iam not very sure that i understand what you mean
    Anyway, I think you should connect the two tables together using the member_id (Are they the same)

    It should be something like

    $q = "Query...
    LEFT JOIN profile u
    ON u.user_id = t.member_id
    ORDER BY... ";
    Code (markup):
    I think you know what i mean
    Hopefully
     
    npsari, Nov 7, 2008 IP
  3. promotingspace.net

    promotingspace.net Peon

    Messages:
    361
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks. I used join and it worked.
    1 other thing is how we can do ordering based on 2 fields. that means for example all data from membertype=1 is shown then membertype=2 etc but each group is ordered by their id (or submission date DESC)? how would the order clause be then?
    thanks for your help
     
    promotingspace.net, Nov 8, 2008 IP