dbTalk Databases Forums  

Sorting the result

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Sorting the result in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Philippe Signoret
 
Posts: n/a

Default Sorting the result - 04-24-2006 , 12:50 AM






If this is in the wrong group lemme know and I'll re-post it to the
correct one. I am using PHP and MySQL.

Suppose I have a table named "servicios" with 5 columns and 200 rows.

If I want to get the whole table sorted by column 3 (suppose the field
name is "nf") I use:

SELECT * FROM `servicios` ORDER BY `nf` ASC

This workd perfectly.

If I want to get just the first 10 rows with _no_ sorting I would use:

SELECT * FROM `servicios` LIMIT 10

This also works perfectly.

Now, if I want to get the first 10 rows, sorted by "nf", I use:

SELECT * FROM `servicios` ORDER BY `nf` ASC LIMIT 10

This does NOT work perfectly. The result I get is the first 10 rows of
whole table which has been sorted by "nf". What I want is just the
resulting first 10 rows to be sorted by "nf", not the whole table.

How can I do this?

Thanks,
Philippe

P.S. I am very new to MySQL, please forgive any unforgivable begginer
mistakes.


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Sorting the result - 04-24-2006 , 02:35 AM






Philippe Signoret (philippe.signoret (AT) gmail (DOT) com) writes:
Quote:
If this is in the wrong group lemme know and I'll re-post it to the
correct one. I am using PHP and MySQL.
Indeed, this is the wrong newsgroup. This news group is for Microsoft
SQL Server. And as your post is about syntax that is peculiar to MySQL,
it's useless that I try to answer.

There is a comp.databases.mysql. Try this instead.



--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #3  
Old   
Philippe Signoret
 
Posts: n/a

Default Re: Sorting the result - 04-24-2006 , 08:20 PM



Thanks you, my apologies.


Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.