sql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

sql

Post by prasadharischandra »

i want to sort a two filed using order by
this is a code
where codeid='$codeid' order by member='Y',rank DESC;
if any know what is wrong ???
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

I'm pretty sure you can't put the member='Y' in the order by clause, you can have order by member, rank DESC;

You will need to limit to 'Y' in the where clause

where codeid='$codeid' and member='Y' order by rank DESC;

What are you really trying to acheive? Do you just want to output members and sort by rank, or do you want to output all users but have members appear first in your listing?

If it the second case and assuming members has 2 values 'Y' or 'N' then

where codeid='$codeid' order by member, rank DESC; will work
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

Post by prasadharischandra »

i want to show the top of the row .
if members yes and rank is high and if perosn doesn't have a member
he goes to down
thank u
JoeMN
Forum Newbie
Posts: 2
Joined: Fri May 17, 2002 2:27 pm

Post by JoeMN »

You can't put the = in the order. Try this:

order by member desc, rank desc

This is assuming that the only values of member are Y and N.
Post Reply