WHERE NOT EXIST附近的语法错误 [英] Syntax Error near WHERE NOT EXIST

查看:316
本文介绍了WHERE NOT EXIST附近的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在堆栈中搜索,但没有一个得到最终答案. 我的查询是这样:

i search in stack but None of them had reached the final answer. My query is this :


    INSERT INTO user (username,frequence,autoSend) 
    VALUES('feri2','3','1') 
    WHERE NOT EXISTS ( SELECT * FROM user WHERE username='feri2')

运行时,我收到语法分析错误:

When run,I receive the syntax parsing error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE NOT EXISTS ( SELECT * FROM user WHERE username='feri2')' at line 1 

我不知道该如何解决,问题出在哪里?

I don't know how I can fix it, where is the problem?

推荐答案

您需要稍微更改语法,请尝试以下操作:

You need to change the syntax slightly, try the following:

INSERT INTO user (username,frequence,autoSend)
SELECT * FROM (SELECT 'feri2','3','1') AS `values`
WHERE NOT EXISTS (
    SELECT username FROM user WHERE username='feri2'
) LIMIT 1;

这篇关于WHERE NOT EXIST附近的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆