List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:May 18 1999 8:19pm
Subject:Re: Problem w/ self-referencing tables population
View as plain text  
On Tue, May 18, 1999 at 06:44:56PM +0200, Gianmarco Armellin wrote:
> CREATE TABLE Level (
> 	id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
> 	descr VARCHAR(30) BINARY,
> 	parent INT REFERENCES Level(id),
> 	UNIQUE (descr)
> )
>  
> INSERT INTO Level VALUES (
> 	NULL, 'Nation', NULL);
> 
> INSERT INTO Level
> 	SELECT NULL, 'Region', ParentLevel.id FROM Level AS ParentLevel WHERE
> ParentLevel.descr='Nation';
> 
> ERROR 1093 at line 12: INSERT TABLE 'Level' isn't allowed in FROM table list

Try to do the second insert into a temporary table.  Then select all of
the rows from the temporary table back into Level.

Tim
Thread
Problem w/ self-referencing tables populationGianmarco Armellin18 May
  • Re: Problem w/ self-referencing tables populationThimble Smith19 May
  • Re: Problem w/ self-referencing tables populationJules Bean19 May