poizn Posted November 26, 2007 Share Posted November 26, 2007 Hi all I have 2 question's. Recently I have started trying to impliment stored procedures in our application, but am having a little trouble learning everything. My first question is can a stored procedure return more than one record. In other words, if I had a stored procedure, that fetched all the records from a table, could I get all the records returned from the stored procedure? DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`p2` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`(OUT user_ids INTEGER(10)) BEGIN SELECT DISTINCT user_id INTO user_ids FROM users; END $$ DELIMITER ; Lets assume this is my simple stored procedure, I call it like so CALL p2(@var); And get the following error message "Error 1172: Result consisted of more than one row" Can anyone help? My second question isn't really a stored procedures question, but more of a query related question. Lets assume I have a users table, with a user_id column. I then have a user_group table, with a user_id, and group_id column. Given that a group can be any size (ie there can be multiple records in the user_group table for a given group) how can I check if a group exists, given the user_id's? And if the group does exist, return the group_id? Can any one help? Thanks in advance Quote Link to comment 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.