"stephen" <[EMAIL PROTECTED]> wrote:
>
> mysql> use zzz
> Database changed
>
>
> mysql> create table category
> -> (
> -> id tinyint(4) NOT NULL auto_increment,
> -> name varchar(20) NOT NULL,
> -> parent tinyint(4) NULL,
> -> primary key(id)
> -> );
> Query OK, 0 rows affected (0.00 sec)
>
>
> mysql> insert into category (name, parent) values('cc_1',null);
> insert into category (name, parent) select 'cc_2a', id from category where
> name = 'cc_1';
> Query OK, 1 row affected (0.01 sec)
>
>
> mysql> insert into category (name, parent) select 'cc_2a', id from category
> where name = 'cc_1';
> ERROR 1066: Not unique table/alias: 'category'
You can add data into the same table tnat you use in the SELECT part only from version
4.0.14.
http://www.mysql.com/doc/en/INSERT_SELECT.html
If you use older version, retrieve data into the temporary table and then insert them
into 'category' table.
>
>
> mysql> show tables;
> +---------------+
> | Tables_in_zzz |
> +---------------+
> | category |
> +---------------+
> 1 row in set (0.00 sec)
>
>
> mysql> status
> --------------
> /usr/local/mysql/bin/mysql Ver 11.17 Distrib 3.23.49a, for pc-linux-gnu
> (i686)
>
> Connection id: 25
> Current database: zzz
> Current user: [EMAIL PROTECTED]
> Current pager: stdout
> Using outfile: ''
> Server version: 3.23.49a
> Protocol version: 10
> Connection: Localhost via UNIX socket
> Client characterset: latin1
> Server characterset: latin1
> UNIX socket: /tmp/mysql.sock
> Uptime: 2 days 14 hours 36 min 36 sec
>
> Threads: 1 Questions: 313 Slow queries: 0 Opens: 70 Flush tables: 1
> Open tables: 15 Queries per second avg: 0.001
> --------------
>
>
> I don't have version 4 at my ISP either.
>
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Egor Egorov
/ /|_/ / // /\ \/ /_/ / /__ [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]