First off I am very new to SQL queries. I do know some basic commands. But i am trying to accomplish something I would consider quite advanced.
I have 4 tables inside 1 database that I need to query information out of. I would like it to return in 3 columns (if possible) 1: "Account ExternalId", 2: "Device ExternalId", 3: "Package Name"
The will be getting the information from these locations.
- mmig.Device.AccountId
- mmig.Device.ExternalId
- mmig.AccountPackage.PackageId
- mmig.Package.Id
- mmig.Account.Id
mmig.Device.AccountId and mmig.Account.Id are Identical values in the column.
mmig.Account.ExternalId should map to the adjacent column mmig.Account.Id (e.g Account.Id = 155 then Account.ExternalId would be V3-0119341)
mmig.AccountPackage.PackageId and mmig.Package.Id are Identical values in the column.
mmig.AccountPackage.PackageId should map to the adjacent column mmig.Package.ExternalId (e.g AccountPackage.PackageId = 17 then Package.ExternalId would be TVPCOFF)
And lastly Device.ExternalId will map to it's adjacent column Device.AccountId (note: there will be multiple Devices for each Account) It is okay if it lists the account number multiple times as long as we have an ORDER By Device.AccountId in there.
Should it have a create_table? to have just the 3 columns I want to display?
Column 1: Name= "Account ExternalId" from table mmig.Account.ExternalId
Column 2: Name= "Device ExternalId" from table mmig.Device.ExternalId
Column 3: Name= "Package Name" from table mmig.Package.ExternalId
If anyone would be able to help mme formulate how this query should look it would be greatly appreciated. If you need any more information to wrap your head around the idea. Let me know.