· 8 years ago · Feb 23, 2018, 07:42 PM
1CREATE DEFINER=`root`@`localhost` PROCEDURE `get_profile_with_templates`(IN _username NVARCHAR(50), IN _template NVARCHAR(50))
2BEGIN
3 SELECT id INTO @template FROM profile_template WHERE name=_template LIMIT 1;
4 SELECT * FROM profile WHERE username=_username AND template=@template LIMIT 1;
5 CREATE TEMPORARY TABLE IF NOT EXISTS sections SELECT * FROM profile_template_section WHERE template=@template;
6 **CREATE TEMPORARY TABLE IF NOT EXISTS components SELECT * FROM component_template WHERE section IN (SELECT id FROM sections);**
7 SELECT * FROM sections;
8 SELECT * FROM components;
9 SELECT * FROM component_template_option WHERE component_template IN (SELECT id FROM components);
10END