0

我一直在环顾四周,但是我看不到我的错误,

我的查询

INSERT INTO p_location_check (location_id) VALUES (1) 
IF NOT EXISTS (SELECT approved, disapproved FROM p_location_check WHERE approved REGEXP '^1234568745$' OR disapproved = '^1234568745$' AND location_id=1); 

只是为了测试之后

INSERT INTO p_location_check (location_id) VALUES (1) 
IF NOT EXISTS (SELECT approved, disapproved FROM p_location_check WHERE approved = 1234568745 OR disapproved = 1234568745 AND location_id=1);

回应

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 2 行的“如果不存在(选择已批准,未批准 FROM qp_location_check WHERE 批准”附近使用正确的语法)

服务器版本

服务器版本:5.5.24-0ubuntu0.12.04.1

4

1 回答 1

0

编辑:

试试这个查询 -

INSERT INTO p_location_check (location_id) VALUES (1) FROM dual
WHERE (SELECT COUNT(*)
       FROM p_location_check
       WHERE approved = 1234568745 OR disapproved = 1234568745 AND location_id=1
       ) = 0;

添加您的 WHERE 条件。

于 2012-10-02T06:49:48.063 回答