开发者

Mysql Temporary Table Syntax

I have a question about the syntax for creating and accessing temporary tables.

Here is a related question.

My table

CREATE TABLE IF NOT EXISTS `table1` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `address` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_开发者_如何转开发INCREMENT=3 ;

--
-- Dumping data for table `table1`
--

INSERT INTO `table1` (`id`, `name`, `address`) VALUES
(1, 'andrew', '5 road'),
(2, 'bob', '6 street');

I am running this query.

CREATE TEMPORARY TABLE temptable SELECT id, name, address
FROM table1
SELECT id, name, address
FROM temptable

And tried this one

CREATE TEMPORARY TABLE temptable SELECT id, name, address
FROM table1
DESCRIBE temptable

Creating the temp table works, but then when I try to get info out of the temp table I get a message saying I need to check my sql syntax. thanks andrew


I left out the ';' after each statement. My query should have looked like this

CREATE TEMPORARY TABLE temptable SELECT id, name, address
FROM table1;
SELECT id, name, address
FROM temptable;

Details are important in programming and so is stackoverflow

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜