我有一张名为 store_contact 的表
+--------------------------+--------------------------+--------------+----------------+
| store_contact_numbers_id | phone_number_description | phone_number | destination_id |
+--------------------------+--------------------------+--------------+----------------+
| 121 | Fax | 5555555555 | 287 |
| 123 | Main | 4444444444 | 287 |
+--------------------------+--------------------------+--------------+----------------+
我需要的上表输出如下所示:
+--------------+------------+
| Phone_Number | Fax_Number |
+--------------+------------+
| 4444444444 | 5555555555 |
+--------------+------------+
我尝试过这样的事情:
select if(phone_number_description='MAIN',phone_number,'') as Phone_Number,
if(phone_number_description='FAX',phone_number,'') as Fax_Number
from store_contact where destination_id=287
但我上面的查询返回如下内容:
+--------------+------------+
| Phone_Number | Fax_Number |
+--------------+------------+
| | 5555555555 |
| 44444444444 | |
+--------------+------------+
我的查询返回两行,其中一为空,但我需要单行。任何人都可以指导我正确的方向来完成它。
谢谢