sql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

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 one know what is wrong ???
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

For your query you should have:
'SELECT * FROM table WHERE codeid='$codeid' ORDER BY member'Y',rank DESC'
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

Post by prasadharischandra »

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

Post by prasadharischandra »

no it's not working
JoeMN
Forum Newbie
Posts: 2
Joined: Fri May 17, 2002 2:27 pm

Post by JoeMN »

order by member DESC, rank DESC

This is assuming that member only has Y,N.
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

Post by prasadharischandra »

hay it's still not working
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post 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
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

But surely 'Y' is greater than 'N'? so a descending order would place Y above N, no?
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post by DSM »

Yea, but he's tried everything else, why not try that.
Post Reply