'where子句中的未知列?

时间:2011-10-10 19:47:42

标签: php mysql

我有以下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子句中的未知列?”我试图改变列的名称,仍然是同样的问题

3 个答案:

答案 0 :(得分:2)

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

match(to_location.id) against(something)

答案 1 :(得分:0)

我猜你可能需要更换

WHERE match(to_location )

WHERE match(to_go.to_location)

答案 2 :(得分:0)

由于您的列名与表名相同,因此MySql可能会让他们感到困惑,并且认为match(to_location)指的是表。请尝试使用完全限定的列名称,即table_name.column_name