The Little Guy Posted May 20, 2011 Share Posted May 20, 2011 Is it possible to do a loop in MySQL outside of a stored procedure? Quote Link to comment https://forums.phpfreaks.com/topic/236973-mysql-loops/ Share on other sites More sharing options...
mikosiko Posted May 20, 2011 Share Posted May 20, 2011 what are you after?.... a better explanation of your objectives could lead to a better answer. short answer... yes... in triggers and/or functions... how to use them is going to depend on your objectives. Quote Link to comment https://forums.phpfreaks.com/topic/236973-mysql-loops/#findComment-1218080 Share on other sites More sharing options...
The Little Guy Posted May 20, 2011 Author Share Posted May 20, 2011 - get a list of member ids - get a sales volume of that members downline (10 levels deep) - get everyone who has sold $100,000 in sales or more (including their downline's sales) in the end, I want a temporary table that has 2 columns: member_id and amount member_id = root member id amount = the sum of the amount of purchases that each member in his/her downline has bought (10 levels deep) any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/236973-mysql-loops/#findComment-1218106 Share on other sites More sharing options...
mikosiko Posted May 20, 2011 Share Posted May 20, 2011 If I understand your objectives correctly simple SELECT's using the proper aggregate functions should answer those queries. and for the temporary table you always can use VIEWS ... in other words: - Create your VIEW with the SELECT aggregating the records in the way you want - Use the VIEW to SELECT from it any further group of records. Quote Link to comment https://forums.phpfreaks.com/topic/236973-mysql-loops/#findComment-1218110 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.