neller Posted November 9, 2009 Share Posted November 9, 2009 Hi, Say I had the following stored function (just a quick demo it does nothing) BEGIN SELECT `name` FROM `customers` WHERE `name` = var_name END How would I check within a procedure how many rows where returned? so if > 0 I can run another query within the function, for example (and this obviously wont work) BEGIN SELECT `name` FROM `customers` WHERE `name` = var_name IF > 0 another query here END thanks in advance ps... alternatively if anybody knows a good tutorial / book on things like the above #i'm more than happy to find it myself. Quote Link to comment https://forums.phpfreaks.com/topic/180839-stored-functions-how-to-check-num_rows/ Share on other sites More sharing options...
ram4nd Posted November 9, 2009 Share Posted November 9, 2009 http://php.net/manual/en/function.mysql-num-rows.php and use the same query. Quote Link to comment https://forums.phpfreaks.com/topic/180839-stored-functions-how-to-check-num_rows/#findComment-954343 Share on other sites More sharing options...
Mchl Posted November 9, 2009 Share Posted November 9, 2009 http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows Quote Link to comment https://forums.phpfreaks.com/topic/180839-stored-functions-how-to-check-num_rows/#findComment-954357 Share on other sites More sharing options...
neller Posted November 10, 2009 Author Share Posted November 10, 2009 Thanks guys, I will check out both those links to see if they solve my problems. Quote Link to comment https://forums.phpfreaks.com/topic/180839-stored-functions-how-to-check-num_rows/#findComment-954983 Share on other sites More sharing options...
Mchl Posted November 10, 2009 Share Posted November 10, 2009 If you want to do it in stored routine, I suggest you start with MySQL's docs Quote Link to comment https://forums.phpfreaks.com/topic/180839-stored-functions-how-to-check-num_rows/#findComment-955009 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.