{"id":1576,"date":"2011-07-19T20:54:00","date_gmt":"2011-07-19T20:54:00","guid":{"rendered":"http:\/\/www.b.shuttle.de\/hayek\/Hayek\/Jochen\/wp\/blog-en\/2011\/07\/19\/sql-limiting-the-number-of-rows-returned\/"},"modified":"2011-07-19T20:54:00","modified_gmt":"2011-07-19T20:54:00","slug":"sql-limiting-the-number-of-rows-returned","status":"publish","type":"post","link":"https:\/\/wp.jochen.hayek.name\/blog-en\/2011\/07\/19\/sql-limiting-the-number-of-rows-returned\/","title":{"rendered":"SQL: Limiting the Number of Rows Returned"},"content":{"rendered":"<p>\t\t\t\t<a href=\"http:\/\/oreilly.com\/catalog\/9780596009762\/\">SQL Cookbook &#8211; O&#8217;Reilly Media<\/a><\/p>\n<div>\n<\/div>\n<div>\nChapter 1 Retrieving Records: Limiting the Number of Rows Returned.<\/div>\n<div>\n<\/div>\n<div>\n<b><br \/><\/b><br \/><b>Problem<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\nYou want to limit the number of rows returned in your query. You are not concerned with the order; any <i>n<\/i> rows will do.<\/div>\n<div>\n<\/div>\n<div>\n<b><br \/><\/b><br \/><b>Solution<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\nUse the built-in function provided by your database to control the number of rows returned.<\/div>\n<div>\n<\/div>\n<div>\n<b><br \/><\/b><br \/><b>DB2<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\n\u2026<\/div>\n<div>\n<\/div>\n<div>\n<b><br \/><\/b><br \/><b>MySQL and PostgreSQL<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\nDo the same thing in MySQL and PostgreSQL using LIMIT:<\/div>\n<div>\n<\/div>\n<div>\n<\/div>\n<blockquote>\n<div>\nselect * from emp limit 5<\/div>\n<div>\n<\/div>\n<\/blockquote>\n<div>\n<\/div>\n<div>\n<b>Oracle<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\n\u2026<\/div>\n<div>\n<\/div>\n<div>\n<b><br \/><\/b><br \/><b>SQL Server<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\n\u2026<\/div>\n<div>\n<\/div>\n<div>\n<br \/><b>Discussion<\/b><\/div>\n<div>\n<\/div>\n<div>\n<br \/>\n\u2026<\/div>\n","protected":false},"excerpt":{"rendered":"<p>SQL Cookbook &#8211; O&#8217;Reilly Media Chapter 1 Retrieving Records: Limiting the Number of Rows Returned. Problem You want to limit the number of rows returned in your query. You are not concerned with the order; any n rows will do. Solution Use the built-in function provided by your database to control the number of rows [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_share_on_mastodon":"0"},"categories":[666],"tags":[],"class_list":["post-1576","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paO0kP-pq","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/1576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/comments?post=1576"}],"version-history":[{"count":0,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/1576\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/media?parent=1576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/categories?post=1576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/tags?post=1576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}