syntax problem i guess

don't work on mysql much but here goes:

I'm trying to
      insert into tbl
      (col1,col2)
      select 'hello','world'
      where not exists (select 1 from tbl where col1 = 'hello')

get an error
i know that on oracle (which i don't work on much either) one needs to select FROM DUAL
is there a requirement like that on mysql or ???

thanks
LVL 25
dgrafxAsked:
Who is Participating?
 
Pratima PharandeCommented:
try this

  insert into tbl
      (col1,col2)
      select 'hello','world' from dual
      where not exists (select 1 from tbl where col1 = 'hello')
0
 
dgrafxAuthor Commented:
"DUAL is purely for the convenience of people who require that all SELECT statements should have FROM and possibly other clauses. MySQL may ignore the clauses. MySQL does not require FROM DUAL if no tables are referenced"
taken from dev.mysql.com

whats your opinion on this?
note that i cannot access that db right now or i would just try it - sorry.
0
 
Kevin CrossChief Technology OfficerCommented:
That is true when no WHERE clause is in place. My experience with 5.5 is with a WHERE clause you get an error without FROM DUAL.
0
 
dgrafxAuthor Commented:
thanks guys
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.