我试图在wordpress数据库上返回基于sql查询的数据表,最终结果将变成csv文件,然后通过电子邮件发送到收件人列表(csv和电子邮件发送工作,它只是数据看起来不正确),使用查询:
SELECT * FROM table_name
这会返回此信息
id | c_id | data_id | name | value
159 | 6 | 15 | salutation | MR
160 | 6 | 15 | full-name | blah
161 | 6 | 15 | phone-number | 123456789
162 | 6 | 15 | email | blah@blah.com
171 | 6 | 16 | salutation | MRS
172 | 6 | 16 | full-name | blah
173 | 6 | 16 | phone-number | 9876543210
174 | 6 | 16 | email | blah2@blah.com
我真正想要返回的是一个看起来像这样的数据表
data_id | salutation | full-name | phone-number | email
15 | MR | blah | 123456789 | blah@blah.com
16 | MRS | blah | 9876543210 | blah2@blah.com
是否有可以执行此操作的查询,或者将php的初始SQL结果重新格式化为我需要的结构?
免责声明在SQL方面我是一个菜鸟,并且只编写了最基本的查询。