syntax problem i guess

Posted on 2011-10-24
Last Modified: 2012-05-12
don't work on mysql much but here goes:

I'm trying to
      insert into tbl
      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 ???

Question by:dgrafx
    LVL 39

    Accepted Solution

    try this

      insert into tbl
          select 'hello','world' from dual
          where not exists (select 1 from tbl where col1 = 'hello')
    LVL 24

    Author Comment

    "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

    whats your opinion on this?
    note that i cannot access that db right now or i would just try it - sorry.
    LVL 59

    Assisted Solution

    by:Kevin Cross
    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.
    LVL 24

    Author Closing Comment

    thanks guys

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now