Find Jobs
Hire Freelancers

Code MySQL VIEW that DYNAMICALLY transposes a table with a single pivot

£10-20 GBP

已完成
已发布超过 7 年前

£10-20 GBP

货到付款
We have one table to transpose on a specific pivot. That table's contents is derived from two other tables in the background. The transpose of rows to columns has to pivot on the product identifier (SKU) and number of rows per SKU is always unknown. BUT the number of columns and their possible contents are derived from another tables (see below). To explain the schema: table to pivot: Name: Feed_SKUs_Attributes id, int(11) [0] SKU, int(11) Attribute , varchar(55) Value, varchar(255) NULL variation_attribute, varchar(3) - a yes/no flag Example data: columns: id SKU, Attribute, Value, variation_attribute data: 439, 2092, Colour, White, yes 440, 2092, Bottle size, Standard (750ml) , yes 54, 2092, ABV , Nonalcoholic, no It is that Feed_SKUs_Attributes table that needs a view created to have one record per SKU, instead of x (in the above example 3). For example, like this instead: columns: SKU, Colour, Colour variation_attribute, Bottle, Bottle variation_attribute, Size, Size variation_attribute, ABV, ABV variation_attribute data: 2092, White, yes, Standard (750ml), yes, Nonalcoholic, no All possible attributes are defined in another table, so the number of columns to create is the number of records in that table SKU_Attributes x2 (x2 for each variation_attribute flag) I don't think this is relevant, but all possible values for the attribute are also set in another table, called SKU_Attribute_Values. I must re-emphasise that this must be totally dynamic and not depend on hardcoding any attribute column names, etc. The second two tables provide the ammunition for the loops probably needed.
项目 ID: 12255959

关于此项目

5提案
远程项目
活跃7 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
Hi! I propose use this manipulation: 1) group attributes in one string with using group_concat. Like this: SELECT GROUP_CONCAT(DISTINCT CONCAT('GROUP_CONCAT(IF(pr.Attribute= ''', pr.`Attribute`, ''', [login to view URL], NULL)) AS ', pr.`code`) ) INTO @SQL FROM SKU_Attributes AS pr; 2) Then add previous statement in select. Like this: SET @SQL = CONCAT('CREATE view viewName as SELECT p.*, ', @SQL, ' FROM Feed_SKUs_Attributes AS p ) GROUP BY [login to view URL];'); 3) PREPARE stmt FROM @SQL; EXECUTE stmt; DEALLOCATE PREPARE stmt; But I need to see schema and check this poroposal. Please send me dump of needed tables.
£23 GBP 在0天之内
4.9 (28条评论)
4.7
4.7
5威客以平均价£49 GBP来参与此工作竞价
用户头像
I'm a full time professional web developer having 5+ years of experience in HTML5, CSS3, jQuery, PHP, mysql, Javascript, Bootstrap, Photoshop, logo designing, shopping carts and CMSs like Wordpress, & more. From full time websites & plugins development to hourly bug fixing I work in flexible hours and can be available online everyday on Skype, phone or email to provide 100% satisfaction and error free nice, professional work.
£18 GBP 在1天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED KINGDOM的国旗
Horley, United Kingdom
5.0
8
付款方式已验证
会员自4月 22, 2016起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。