Skip to main content

How to Use Limit Clause in MySQL Procedure

well, there is some trouble when you want to use limit clause with input parameter in Store Prosedure. Since July 2005, Markus Popp was report this problem as bug and also request for new feature. until now, MySQL didn't support yet this feature.

as an alternative solution, use prepare statement to identifiy limit variable like this following code:
delimiter //
drop procedure if exists limitTest //
create procedure limitTest( idin int )
begin
set @sql = concat('select * from mytable order by id limit ', idin );
prepare stmt from @sql;
execute stmt;
drop prepare stmt;
end //
delimiter ;
call limittest(5);


related documents:
http://bugs.mysql.com/bug.php?id=11918
http://forums.mysql.com/read.php?98,28212
http://bugs.mysql.com/bug.php?id=33856

Comments

Popular posts from this blog

Langkah mudah membuat aplikasi sendiri di Facebook

konten diperbaharui karena sudah tidak relevan. Getting Started Websites Apps on Facebook Mobile Samples & How-Tos Videos Core Concepts Social Design Social Plugins Open Graph protocol Social Channels Authentication Graph API Advanced Topics Dialogs FQL Internationalization Ads API Credits API Chat API Legacy REST API Legacy FBML Legacy FBJS Legacy Javascript SDK SDKs & Tools Open Graph Beta -----iklan----- ----- lihat juga: >> Belajar Cara Membuat Software >> Contoh Source Code Aplikasi Facebook penasaran banget nih pingin nyobain bikin aplikasi di Facebook.com. perlu kalian tahu, kalo facebook udah menyediakan API yang bisa anda gunakan di aplikasi anda. fitur integrated seperti ini akan memberikan "kesan" seolah - olah kita tidak pernah beranjak dari facebook. projek sebuah aplikasi di facebook sepertinya akan menjadi hal yang menarik. Gath adam sudah membuat artikel tentang cara membuat apl...

Powerful job portal with university web integration

Creating a powerful job portal with university web integration involves combining cutting-edge technology, strategic partnerships, and a user-centric approach to bridge the gap between academia and industry. In this comprehensive explanation, I'll delve into the key components and benefits of such a platform.

Embracing Nostalgia: Exploring Retrogameplanet and the Joy of Playing Retro Games on the Web

In a world dominated by cutting-edge graphics and virtual reality experiences, there's a unique charm in revisiting the past. Retrogameplanet stands as a digital oasis, providing enthusiasts with a portal to relive the magic of classic games from bygone eras. As the name suggests, Retrogameplanet is more than just a website; it's a vibrant community and a haven for those who appreciate the simplicity and nostalgia associated with retro gaming.