By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,412 Members | 1,630 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,412 IT Pros & Developers. It's quick & easy.

Sorting the result

P: n/a
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.

Apr 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Philippe Signoret (ph***************@gmail.com) writes:
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, es****@sommarskog.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
Apr 24 '06 #2

P: n/a
Thanks you, my apologies.

Apr 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.