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
ordering from another table
Moderator: General Moderators
Re: ordering from another table
It's best to keep the information in two separate tables. A membership table would contain all membership information. When you need that information for sorting, join back to that table and use it in an ORDER BY clause.
Re: ordering from another table
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
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
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: ordering from another table
m2babaey wrote: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
Code: Select all
SELECT A.*
FROM table1 A,
table2 B
WHERE A.column1 = B.column2
ORDER BY A.column1,
B.column3 DESC