Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > Database & Database Programming

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

Database & Database Programming MySQL, Oracle, SQL, PL/SQL, ABAP, Smart Forms, and other databases and languages. A database is an organized body of related information used in many websites (including CC).

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-2006, 11:32 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default Limit number of listings

Is there a way in MySQL to limit how many results are shown?

SELECT * FROM tbl;

but I only want say, 25 results. Is this possible?
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-15-2006, 08:26 PM
smith smith is offline
Programmer
 
Join Date: Jun 2006
Posts: 108
Credits: 0
Rep Power: 9
smith is on a distinguished road
Default

Yup, just add a LIMIT 0,25

The 0 is where to start and the 25 is the max number of results.
__________________
Code:
for (int i;;) {
   cout << "Smith";
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-15-2006, 08:27 PM
smith smith is offline
Programmer
 
Join Date: Jun 2006
Posts: 108
Credits: 0
Rep Power: 9
smith is on a distinguished road
Default

SELECT * FROM tbl LIMIT 0,25;
__________________
Code:
for (int i;;) {
   cout << "Smith";
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-17-2006, 12:17 AM
husky44's Avatar   
husky44 husky44 is offline
Learning Programmer
 
Join Date: Jun 2006
Posts: 30
Credits: 0
Rep Power: 9
husky44 is on a distinguished road
Default

I know there is a command for Top 10 or something.. how does that one work?
Sorry to slightly stray here, but it is still kind of relevant.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-17-2006, 07:52 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 7,330
Last Blog:
Tramp Variables
Credits: 1
Rep Power: 20
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

You can do a ORDER BY to get the top ten combined with limit

SELECT * FROM tbl ORDER BY clm_num LIMIT 0,10;

Do to in reverse order do

SELECT * FROM tbl ORDER BY clm_num LIMIT 0,10 DESC; // Descending Order

You can also ORDER by multiple columns in your table

SELECT * FROM tbl ORDER BY clm_num, clm_name LIMIT 0,10;

If the column is character it will be sorted alphabetical.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to calculate the number of pixels in a polygon extreme Java Help 5 04-17-2007 10:34 AM
Number Cloning Ronin Java Help 3 12-21-2006 07:23 AM
I need to generate a random number in PHP dirkfirst PHP Forum 7 07-05-2006 09:58 PM
Number of Lines on a RichText Box Lop Managed C++ 3 06-16-2006 05:19 PM
Number of files and directories in folder dirkfirst PHP Forum 4 05-30-2006 10:06 AM


All times are GMT -5. The time now is 02:09 AM.

Contest Stats

Xav ........ 1322.18
MeTh0Dz|Reb0rn ........ 1053.7
morefood2001 ........ 879.43
John ........ 877.37
marwex89 ........ 869.98
WingedPanther ........ 830.24
Brandon W ........ 735.07
chili5 ........ 309.39
Steve.L ........ 239.84
dcs ........ 216.02

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads