开发者

PHP MySQL join help

I have 3 tables, companies, industries and company_industry.

In companies, I store information about companies and in industries there's some common industries to attach to the company. So in the table company_industry I store the ID of the company and the industry.

My problem is that I want to do a full开发者_JAVA百科text search of the company including the industry. I know it has something to do with join, but this is far to advanced than I can handle.


The full text search I'm not so sure about, but the JOIN is fairly easy.

SELECT * FROM company JOIN company_industry ON company.id = company_industry.company JOIN industry ON company_industry.industry = industry.id;

As a side note, unless a company can be part of multiple industries, the company_industry table is not required.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜