Page 1 of 1
sql
Posted: Thu May 16, 2002 4:15 am
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 one know what is wrong ???
Posted: Thu May 16, 2002 10:57 am
by fatal
For your query you should have:
'SELECT * FROM table WHERE codeid='$codeid' ORDER BY member'Y',rank DESC'
Posted: Fri May 17, 2002 12:31 am
by prasadharischandra
Yes
Posted: Fri May 17, 2002 5:05 am
by prasadharischandra
no it's not working
Posted: Fri May 17, 2002 2:31 pm
by JoeMN
order by member DESC, rank DESC
This is assuming that member only has Y,N.
Posted: Sat May 18, 2002 6:50 am
by prasadharischandra
hay it's still not working
Posted: Sat May 18, 2002 9:42 am
by DSM
I would switch from using "Y" & "N" to "1" for "Yes" and "0" for "NO" then you can write your query as
$sql = mysql_query("SELECT * FROM table WHERE codeid=\"$codeid\" ORDER BY member DESC, rank DESC");
1 is greater than 0 and by selecting in DESC order would place all the 1's first than the 0's
Posted: Sun May 19, 2002 12:41 pm
by mikeq
But surely 'Y' is greater than 'N'? so a descending order would place Y above N, no?
Posted: Sun May 19, 2002 12:46 pm
by DSM
Yea, but he's tried everything else, why not try that.