在多列中拆分一列 [Wordpress]

Split one column in many columns [Wordpress]

晚上好,

我想帮我把一个列拆分成多个列,我试了很多情况都没有成功...

I have a table in which the entries are made in a column name -> value:

photo image sample 1

And I want to convert and to catch through from Query (Select):

photo image sample 2

如有解决方案将不胜感激... 谢谢!

试试这个查询。 (假设 [test] 是你的 table 名字)

SELECT
 t.lead_id
 , t.form_id
-- sub-query for Value1
, (SELECT VALUE FROM test as inner_t WHERE inner_t.lead_id = t.lead_id and inner_t.form_id = t.form_id 
                                       and inner_t.field_number = 1) as value1
-- sub-query for Value2
, (SELECT VALUE FROM test as inner_t WHERE inner_t.lead_id = t.lead_id and inner_t.form_id = t.form_id 
                                       and inner_t.field_number = 2) as value2
-- sub-query for Value3
, (SELECT VALUE FROM test as inner_t WHERE inner_t.lead_id = t.lead_id and inner_t.form_id = t.form_id 
                                       and inner_t.field_number = 3) as value3
-- sub-query for Value4
, (SELECT VALUE FROM test as inner_t WHERE inner_t.lead_id = t.lead_id and inner_t.form_id = t.form_id 
                                       and inner_t.field_number = 4) as value4
FROM test AS t
GROUP BY lead_id, form_id