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 | |
+--------------+------------+
私のクエリは2行を返しますが、1行は空ですが、1行が必要です。誰でもそれを成し遂げるために正しい方向に私を導いてください。
ありがとう