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' 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. Thanks ----- Original Message ----- From: "cvarda" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 15, 2004 10:57 PM Subject: Re: How could I do this insert/select? > It seems to work on my MySQL (4.0.18). > > Tell us which version are you using and the error code/message returned. > > ------ excerpt ------------------------------------------ > 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.03 sec) > > mysql> insert into category (name, parent) values('cc_1',null); > Query OK, 1 row affected (0.01 sec) > > mysql> > mysql> insert into category (name, parent) select 'cc_2a', id from category > where name = 'cc_1'; > Query OK, 1 row affected (0.01 sec) > Records: 1 Duplicates: 0 Warnings: 0 > > mysql> select * from category; > +----+-------+--------+ > | id | name | parent | > +----+-------+--------+ > | 1 | cc_1 | NULL | > | 2 | cc_2a | 1 | > +----+-------+--------+ > 2 rows in set (0.00 sec) > > mysql> > ------ excerpt ------------------------------------------ > > > []s, > Conrado > > > > ----- Original Message ----- > From: "stephen" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, March 16, 2004 2:57 AM > Subject: How could I do this insert/select? > > > > Hi, > > > > How could I do this insert/select? > > > > create table category > > ( > > id tinyint(4) NOT NULL auto_increment, > > name varchar(20) NOT NULL, > > parent tinyint(4) NULL, > > primary key(id) > > ); > > > > insert into category (name, parent) values('cc_1',null); > > insert into category (name, parent) select 'cc_2a', id from category where > > name = 'cc_1'; > > > > MySQL don't like the insert/select. > > > > Thanks > > > > > > > > > > -- > > 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] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]