I have a simple table schema:
Person: ID, Name PhoneNumber: ID, Type, Number #Type can be 'home' or 'mobile'. PersonPhoneNumber: ID, Person_ID, PhoneNumber_ID #A join table that connects the #person to a phone number. As data I have:
Person: 1, "Ed" PhoneNumber: 1, "home", 1111 PhoneNumber: 2, "mobile", 2222 PersonPhoneNumber: 1, 1 /*(Person_ID)*/, 1 /*(PhoneNumber_ID*/ PersonPhoneNumber: 2, 1 /*(Person_ID)*/, 2 /*(PhoneNumber_ID*/ I want to write a view that returns:
Name |Home |Mobile ----------------------------- "Ed" 1111 2222 "Joe" 3333 4444 ... etc Any tips on how I approach this?
Note: These tables are a snippet from a larger schema which explains why its a many to many and not more simplistic.