where子句中的未知列


Unknown column in 'where clause?

我有以下php代码

        $query = sprintf("SELECT to_go.to_location FROM to_go 
                INNER JOIN to_location ON to_go.to_location_id = to_location.id 
                    WHERE match(to_location ) against(%s)", mysql_real_escape_string($location));

我尝试了一切,但它保持输出我以下错误"未知列在'where子句?"我试图改变列的名称,仍然是相同的问题

match(to_location ) against需要提供一个字段,而不是一个表:

match(to_location.id) against(something)

我想你可能需要替换

WHERE match(to_location )

WHERE match(to_go.to_location)

由于列名与表名相同,MySql可能会混淆它们并认为match(to_location)指的是表。尝试使用完全限定的列名,即table_name.column_name