From 62eccaa3daf4e9680c561dbc6034b74f3c83b13b Mon Sep 17 00:00:00 2001 From: niekt0 Date: Tue, 15 Mar 2011 02:14:45 +0100 Subject: [PATCH] sql function fix --- wwwroot/backend/mysql/functions.sql | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/wwwroot/backend/mysql/functions.sql b/wwwroot/backend/mysql/functions.sql index 801dc83..b5c81a1 100644 --- a/wwwroot/backend/mysql/functions.sql +++ b/wwwroot/backend/mysql/functions.sql @@ -34,11 +34,23 @@ BEGIN END WHILE; RETURN final; END// + +/* Procedure itself with additional informations (parent name and owner name)*/ create procedure k_neurons ( IN user_id INT, IN day_int INT) BEGIN if day_int = NULL or day_int = 0 then set day_int=20; end if; - select *,(k_get_node_weigth(node_id,user_id)*k) as weight_k,'test1' as creator,'test2' as parent from nodes where k>0 - and node_created>now()-interval day_int day order by weight_k desc; - + select nodes.node_id, + nodes.node_name, + nodes.node_creator, + nodes.node_content, + nodes.node_parent,(k_get_node_weigth(nodes.node_id,user_id)*nodes.k) as weight_k, + users.login as creator_name, + parent.node_name as parent_name + from nodes + left join users on users.user_id=nodes.node_creator + left join nodes as parent on nodes.node_parent=parent.node_id + where nodes.k>0 and nodes.node_created>now()-interval day_int day + order by weight_k desc; + END// delimiter ; -- 2.30.2