I have 3 tables: Device, Service, DeviceXService
Table (Device) has a list of devices and fields associated to the devices such as serial number device name etc.
DeviceID | Device Name | SerialNumber 1 | iPhone | 2352532533 2 | iPad | 2345435435 3 | android | 2532532656
Table (Service) is a lookup table that has a list of services that can be used on devices such as email, internet, texting etc.
ServiceID | ServiceName 1 | email 2 | internet 3 | texting
Table (DeviceXService) is a cross-reference table that has a record linking devices to services and the status of those devices.
For example.
DeviceID | ServiceID | Status -------------------------------------- 1(iPhone) | 1(email) | requested 2(ipad) | 2(internet) | Approved 1(iPhone) | 3(texting) | Approved 3(android) | 3(texting) | approved
What I would like to do is create a query that would return all the devices FROM the Devices table, but also create a column for each type of service that exists FROM the Service table and return the status of each service for each device FROM the DeviceXService cross-reference table as one table.
example:
Device ID | Device Name | Device Serial No | email | texting | internet -------------------------------------------------------------------------------- 1 | iphone | 2352532533 | requested| approved | null 2 | ipad | 2345435435 | null | null | approved 3 | android | 2532532656 | null | null | approved
Note: null is if the device doesn't have a record for the service in the DeviceXService cross-reference table
I apologize if I'm not explaining this very well but that may be why I'm having such a hard time trying to find an example of something similar. Any help would be greatly appreciated!