I have a large database that has about 190 columns in 22 tables. There are a few tables that allow multiple entries into the database all of the values are referenced by a foreign key. When I use a LEFT OUTER JOIN
If there are multiple entries in a single column matching a specific ID then it creates a new row with all of the information as before only changing the table fields. For example:
+-----------+---------------------------+-----------------------------+----------------+-------+-------+---------+-------------------------------+
| CompanyID | Name | Address | City | State | Zip | Country | Website |
+-----------+---------------------------+-----------------------------+----------------+-------+-------+---------+-------------------------------+
| 227 | Hello Company | 123 blvd | Boom | OK | 56008 | USA | www.imtired.com |
| 228 | Test Company | 87 Wesley Street | Denham | LA | 21726 | USA | www.tests.com |
| 229 | Testing Company | 2 US hwy 281 N. | Antonio | TX | 64258 | USA | www.modeling.com |
| 230 | TestCompany | 45 W. 95th St | Oak Lawn | IL | 61453 | USA | www.express.com |
| 235 | Encore | 2142 S. Patterson | City | IA | 43106 | USA | www.boomsite.com |
| 235 | Encore | 2142 S. Patterson | City | IA | 43106 | USA | www.testingsite.com |
+-----------+---------------------------+-----------------------------+----------------+-------+-------+---------+-------------------------------+
You see that the company Encore has two rows with only the website being different is there a way to make it like this:
+-----------+---------------------------+-----------------------------+----------------+-------+-------+---------+-------------------------------+
| CompanyID | Name | Address | City | State | Zip | Country | Website |
+-----------+---------------------------+-----------------------------+----------------+-------+-------+---------+-------------------------------+
| 227 | Hello Company | 123 blvd | Boom | OK | 56008 | USA | www.imtired.com |
| 228 | Test Company | 87 Wesley Street | Denham | LA | 21726 | USA | www.tests.com |
| 229 | Testing Company | 2 US hwy 281 N. | Antonio | TX | 64258 | USA | www.modeling.com |
| 230 | TestCompany | 45 W. 95th St | Oak Lawn | IL | 61453 | USA | www.express.com |
| 235 | Encore | 2142 S. Patterson | City | IA | 43106 | USA | www.boomsite.com |
| | | | | | | | www.testingsite.com |
+-----------+---------------------------+-----------------------------+----------------+-------+-------+---------+-------------------------------+
This is a snippet of the query I am using :
SELECT * FROM `company` C
LEFT OUTER JOIN owner O USING ( CompanyID )
LEFT OUTER JOIN sales S USING ( CompanyID )