我在数据库中有两个表,公司和 line_of_business ,我想从表公司中获取所有数据表 type_of_business 中的 line_of_business 列。
这是表公司的字段:
id,
company,
address,
city,
tel_number,
fax_number,
line_of_business(FRK)
这是表line_of_business的字段:
id,
type_of_business,
description
我尝试使用此处的引用对数据库进行查询。 http://www.w3schools.com/sql/sql_join_inner.asp,但结果为#1054 - Unknown column 'companies.company' in 'field list',
,表格中存在公司列公司
这是我的查询,
SELECT `companies.id`, `companies.company`, `companies.address`, `companies.city`, `companies.tel_number`, `companies.fax_number`, `companies.tax_number`, `line_of_business.type_of_business` FROM `companies` INNER JOIN `line_of_business` ON `line_of_business.id`=`companies.line_of_business`
是否有正确的方法来进行连接查询?
答案 0 :(得分:2)
您可以使用companies
。company
代替companies.company
获取所有列