It seems Victoria didn't understand the real problem:

I think that query should be stopped as soon as the table exists.
But if it doesn't exist, the query should create it and insert some records.
The problem is: WHY is MySQL trying to insert records while the table
exists? It should only insert records after creating the table (and table
will be created only when t doesn't exist already).
So, in that query, will the IF condition apply for table creation only?


Thanks
Emery
----- Original Message -----
From: "Victoria Reznichenko" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 29, 2003 11:37
Subject: Re: 'IF NOT EXISTS' ignored?


> Hassan Schroeder <[EMAIL PROTECTED]> wrote:
> > Is there a problem with 'IF NOT EXISTS' in the following scenario?
> >
> > This statement creates the table as expected ...
> >
> > CREATE TEMPORARY TABLE IF NOT EXISTS
> >        showcase (
> >                  PRIMARY KEY (product)
> >                  )
> > SELECT product FROM productList
> >
> > .. but re-running it (from the console or via page reload) results
> > in  "ERROR 1062: Duplicate entry 'foo' for key 1"
> >
> > I expected it to simply exit silently when it finds that the table
> > *does* already exist. So what am I missing?  :-)
>
> "Duplicate entry" means that you already have value 'foo' in the column
'product' which is defined as primary key.
>
>
> --
> For technical support contracts, goto https://order.mysql.com/?ref=ensita
> This email is sponsored by Ensita.net http://www.ensita.net/
>    __  ___     ___ ____  __
>   /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
>  / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
> /_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
>        <___/   www.mysql.com
>
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to