Closed Thread Icon

Topic awaiting preservation: php sort (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=24384" title="Pages that link to Topic awaiting preservation: php sort (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: php sort <span class="small">(Page 1 of 1)</span>\

 
EDDII
Bipolar (III) Inmate

From:
Insane since: May 2004

posted posted 12-13-2004 23:59

yo does anybody know how i can sort mysql data by one thing then another for example i might want to sort somthing by age then name so instead of showing 20 year olds at random then 21 year olds at random and so on it would give me all the 20 yea olds in alphabetical order then the 21 year olds in alphabetica order and so on

p.s. i am also wondering how i can select data on the first letter of a colum so it selects all the rows with a name begining with a only

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 12-14-2004 00:23

Why doing this in PHP while your SQL query can do it for you ?
Try something like :

select * my_table where CONDITION oder by age asc, name asc

Hope that helps,

Hebedee
Paranoid (IV) Inmate

From: Maryland, USA
Insane since: Jan 2001

posted posted 12-14-2004 05:02

I am sure you realize this, but it is Order By, rather than oder by.


code:
SUBSTRING(str FROM pos FOR len)
The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos. The forms that use FROM are standard SQL syntax.

mysql> SELECT SUBSTRING('Quadratically',5);
-> 'ratically'
mysql> SELECT SUBSTRING('foobarbar' FROM 4);
-> 'barbar'
mysql> SELECT SUBSTRING('Quadratically',5,6);
-> 'ratica'

This function is multi-byte safe.



From http://dev.mysql.com/doc/mysql/en/String_functions.html

So to find rows where the first letter of a certain column value is A, you could say that the CONDITION poi mentioned above is:

SUBSTRING(column, 0,1) = 'a'

Or some such.

crip
Bipolar (III) Inmate

From: iasi, romania
Insane since: Apr 2002

posted posted 12-14-2004 08:53

... WHERE column LIKE 'a%';


Curiously yours, crip

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 12-14-2004 23:09

Hebedee: oops, sorry that was a typo indeed. Damn, I miss my Natural Keyboard this one is all flat.

« BackwardsOnwards »

Show Forum Drop Down Menu