添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
不爱学习的墨镜  ·  极米投影仪 New H3S·  3 月前    · 
爽快的春卷  ·  广州市科学技术局网站·  4 月前    · 
越狱的大脸猫  ·  String to NSString to ...·  5 月前    · 

I am trying to perform INSERT WHERE NOT EXISTS in singlestore using spring jpa native quey but I’m getting Sql grammar exception. I’m using sql5dialect.

Can someone help me with performing the query

Query - INSERT INTO table(col1) VALUES (‘colValue’) WHERE NOT EXISTS (SELECT 1 from table WHERE col2 = ‘coValue’

I have also tried INSERT INTO table(col1) Select (‘colValue’) from dual WHERE NOT EXISTS (SELECT 1 from table WHERE col2 = ‘coValue’

Hi EricB,

This query should work :
INSERT INTO table(col1) select ‘colValue’ from dual WHERE NOT EXISTS (SELECT 1 from table WHERE col2 = ‘coValue’);
Are you able to use it in your code instead of the auto-generated one?

Actually we are using native query in jpa and not auto generated. But even running the insert statement as is did not work
I am using database console from intellij for running the commands

INSERT INTO table(col1, col2, col3) select (‘colValue1’, ‘colValue’, ‘colValue’ ) from dual WHERE NOT EXISTS (SELECT 1 from table t WHERE t.col1 = ‘colValue1’ AND t.col2 = ‘coValue’);

Error - check the manual the corresponds to your MySQL version for the right syntax to use near
‘, colValue, colValue ) from dual WHERE NOT’