CREATE table #wp_usermeta ([Id] int, [meta_key] varchar(6...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Puzzling Meta

Q&A for those who study the creation and solving of puzzles

CREATE table #wp_usermeta
    ([Id] int, [meta_key] varchar(6), [meta_value] varchar(13))
;
    
INSERT INTO #wp_usermeta
    ([Id], [meta_key], [meta_value])
VALUES
    (1, 'John', 'nickname'),
    (5, '857685', 'billing_phone')
;


select nickname, billing_phone
from
(
  select meta_key, meta_value
  from #wp_usermeta
) d
pivot
(
  max(meta_key)
  for meta_value in (nickname, billing_phone)
) piv;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results