|
|
|
Custom Search
| |
|
| |
|
Use LIMIT Clause to Constrain the Number of Rows Returned
If a table contains one million rows and you only want to retrieve data from row 1 to row 100, you can use the LIMIT clause. The LIMIT clause is used to constrain the number of rows returned by the SELECT statement. Read Prerequisites for this tutorial and practices if you haven't done so. Consider the following facts when using LIMIT clause in a SELECT statement:
Practice #1: Use two numeric arguments in LIMIT clause In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. Note that the SQL needs to end with semi-colon if you have multiple queries in the query window. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /*
Query result set - 10 rows returned: Practice #2: Use one argument in LIMIT clause In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. Note that the SQL needs to end with semi-colon if you have multiple queries in the query window. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /*
Query result set - 15 rows returned: Practice #3: Using LIMIT 0 to validate a query rather than execute it In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. Note that the SQL needs to end with semi-colon if you have multiple queries in the query window. Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. /* LIMIT 0 is very useful when you need to validate a complex query. Sometimes when you expect a query to return a large number of rows but you are not sure if the SQL syntax is correct, you can use LIMIT 0 to validate the query. This reduces server load.
Query result set - 0 rows returned:
|
|
Copyright © 2012 GeeksEngine.com. All Rights Reserved. This website is hosted by LunarPages. No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it. |
| Home | Kung Fu Timer | Feedback | Terms of Use | Privacy Policy |