gpt4 book ai didi

mysql - 清理 MySQL 查询、Wordpress wp_postmeta

转载 作者:行者123 更新时间:2023-11-29 08:05:21 25 4
gpt4 key购买 nike

SELECT 
post_id,meta_key,meta_value
FROM
wp_postmeta
WHERE
post_id > 3185 AND
meta_key = '_shipping_first_name' OR
post_id > 3185 AND
meta_key = '_shipping_last_name' OR
post_id > 3185 AND
meta_key = '_shipping_postcode'
ORDER BY post_id

post_id meta_key meta_value
3186 _shipping_first_name Joe
3186 _shipping_last_name Svelnys
3186 _shipping_postcode 06040

这是输出数据。我正在尝试将其格式化为

Order  FName  LName    Zip    
3186 Joe Svelnys 06040

有什么想法吗?我真的很感激。

这里有一个 Sqlfiddle 可以帮助您 http://sqlfiddle.com/#!2/83e232

最佳答案

select post_id as OrderNo, 
(select meta_value from wp_postmeta where post_id = w.post_id and meta_key = '_shipping_first_name') as FName,
(select meta_value from wp_postmeta where post_id = w.post_id and meta_key = '_shipping_last_name') as LName,
(select meta_value from wp_postmeta where post_id = w.post_id and meta_key = '_shipping_postcode') as Zip
from wp_postmeta w where w.post_id > 3185 group by post_id

在这里摆弄:http://www.sqlfiddle.com/#!2/b3606/10

关于mysql - 清理 MySQL 查询、Wordpress wp_postmeta,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22840109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com