I have two tables, staff
and phones
.
Staff
has only one field, staff_id
. Phones
has three fields: staff_id
, phone_type
and number
.
I want to display the staff_id, cell phone number and home phone number of all staff members. But I can't figure out how to have cell phone number and home phone number as separate columns in the result. Here's what I've been trying so far, which puts both types of numbers in the same column.
SELECT staff.staff_id, phones.number
FROM staff
LEFT JOIN phones ON ( staff.staff_id = phones.staff_id && ( phones.field_type = 'Cell' || phones.field_type = 'Home' ) )