托管在000webhost上时的SQL语法

时间:2015-01-28 21:53:30

标签: mysql syntax-error mysql-error-1064

我正在尝试在本地主机上运行PHP代码中的MySQL查询。当我托管数据库和PHP页面时,它运行得很好。 000webhost的phpMyAdmin数据库不断用错误的SQL语法调用我的查询。我已经重新检查了列名,但它们都是相同的。

以下是我的查询和000webhost数据库给出的错误:

select * from taxi
    where 'registration_number' NOT IN (
        select 'taxi_registration_number' from shift
        where 'shift_date' = 'sysdate'
    );

给出的错误是

  

1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在第2行的''附近使用正确的语法

2 个答案:

答案 0 :(得分:2)

您不能在列标识符周围使用单引号。要么使用刻度线,要么根本不使用。

SELECT 
    *
FROM
    taxi
WHERE
    `registration_number` NOT IN (SELECT 
            `taxi_registration_number`
        FROM
            shift
        WHERE
            `shift_date` = 'sysdate');

答案 1 :(得分:0)

删除引号:

select * from taxi where registration_number NOT IN (
   select taxi_registration_number from shift where shift_date = 'sysdate'
);