Sorting database table values by various criteria

This is a discussion on Sorting database table values by various criteria within the PHP Language forums, part of the PHP Programming Forums category; How can I sort some sports tables from database by mulitple criteria? If two teams have the same point numbers ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2005
Goran Ljubej
 
Posts: n/a
Default Sorting database table values by various criteria

How can I sort some sports tables from database by mulitple criteria?
If two teams have the same point numbers i have to check for some
additional conditions...
Is this possiblein SQL QUERY string or do i have to do it in php?

how do i do it in either way?

thnx
Reply With Quote
  #2 (permalink)  
Old 04-16-2005
jerry gitomer
 
Posts: n/a
Default Re: Sorting database table values by various criteria

Goran Ljubej wrote:
> How can I sort some sports tables from database by mulitple criteria?
> If two teams have the same point numbers i have to check for some
> additional conditions...
> Is this possiblein SQL QUERY string or do i have to do it in php?
>
> how do i do it in either way?
>
> thnx


Try something along the line of:

SELECT col1, col2, ...
FROM mytable
WHERE cond1 AND cond2
ORDER BY cola, colx;

Reply With Quote
  #3 (permalink)  
Old 04-16-2005
Goran Ljubej
 
Posts: n/a
Default Re: Sorting database table values by various criteria

jerry gitomer wrote:

> Goran Ljubej wrote:
>
>> How can I sort some sports tables from database by mulitple criteria?
>> If two teams have the same point numbers i have to check for some
>> additional conditions...
>> Is this possiblein SQL QUERY string or do i have to do it in php?
>>
>> how do i do it in either way?
>>
>> thnx

>
>
> Try something along the line of:
>
> SELECT col1, col2, ...
> FROM mytable
> WHERE cond1 AND cond2
> ORDER BY cola, colx;
>

this order by... does that mean that it will first order by cola and
then if the same cola it'll order by colx???

if yes than it might be something i am looking for...
Reply With Quote
  #4 (permalink)  
Old 04-16-2005
Andy Hassall
 
Posts: n/a
Default Re: Sorting database table values by various criteria

On Sat, 16 Apr 2005 15:38:19 +0200, Goran Ljubej <goran.ljubej@mail.inet.hr>
wrote:

>jerry gitomer wrote:
>
>> Goran Ljubej wrote:
>>
>>> How can I sort some sports tables from database by mulitple criteria?
>>> If two teams have the same point numbers i have to check for some
>>> additional conditions...
>>> Is this possiblein SQL QUERY string or do i have to do it in php?
>>>
>>> how do i do it in either way?

>>
>> Try something along the line of:
>>
>> SELECT col1, col2, ...
>> FROM mytable
>> WHERE cond1 AND cond2
>> ORDER BY cola, colx;
>>

>this order by... does that mean that it will first order by cola and
>then if the same cola it'll order by colx???
>
>if yes than it might be something i am looking for...


What happened when you tried it? But the short answer is yes.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Reply With Quote
  #5 (permalink)  
Old 04-16-2005
Goran Ljubej
 
Posts: n/a
Default Re: Sorting database table values by various criteria

Andy Hassall wrote:

> On Sat, 16 Apr 2005 15:38:19 +0200, Goran Ljubej <goran.ljubej@mail.inet.hr>
> wrote:
>
>
>>jerry gitomer wrote:
>>
>>
>>>Goran Ljubej wrote:
>>>
>>>
>>>>How can I sort some sports tables from database by mulitple criteria?
>>>>If two teams have the same point numbers i have to check for some
>>>>additional conditions...
>>>>Is this possiblein SQL QUERY string or do i have to do it in php?
>>>>
>>>>how do i do it in either way?
>>>
>>>Try something along the line of:
>>>
>>> SELECT col1, col2, ...
>>> FROM mytable
>>> WHERE cond1 AND cond2
>>> ORDER BY cola, colx;
>>>

>>
>>this order by... does that mean that it will first order by cola and
>>then if the same cola it'll order by colx???
>>
>>if yes than it might be something i am looking for...

>
>
> What happened when you tried it? But the short answer is yes.
>

thanks a lot... I havent tried it yet... I'm just thinking about how
would i do it... :)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:27 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0