I know there's got to be a way to do this, but for the life of me I can't figure it out:
I have 3 tables I want to join together (simplified to illustrate):
users
uid mail
1 [email protected]
2 [email protected]
3 [email protected]
profile_fields
fid name label
1 full_name Full Name
2 phone Phone
profile_values
uid fid value
1 1 Q Q
1 2 5555555555
2 1 Ww Ww
3 2 4444525411
I'd like to get results of the form:
uid mail full_name phone
1 [email protected] Q Q 5555555555
2 [email protected] Ww Ww NULL
3 [email protected] NULL 44445454111
I've tried various SELECTs with different JOIN conditions but I can't seem to figure out how to get the rows of profile_fields to be my columns in my SELECT
EDIT: I've also tried googling around, but I can't seem to figure out how to phrase this to google.