My companies table contains detail data such as company name.
My sites table maps to the companies table in the company_sites table because companies can have multiple sites.
For example, Jim Co (id: 1000) has jim.com (id: 2000).
These are mapped as company_sites:id = 1; company_id: 1000; site_id: 2000.
How can I select all fields for Jim Co from companies where site_id = 2000?
I'm getting an alias error for companies when I try this.
Here's what I have so far:
SELECT *
FROM companies
INNER JOIN companies ON companies.id = company_sites.company_id
WHERE company_sites.site_id = 2000