1. 在MYSQL中 insert ...select 和 select .... insert .....有什么区别?
另外请教一个问题:
如何把A表的内容复制到一个尚不存在的B表中,并且在B表的最后添加一个当前时间的列,并赋上值;
A表
create table A
(
id int primary key auto_increment,
name varchar(200) not null
);
insert into A values(1,'A');
insert into A values(2,'B');
insert into A values(3,'C');
insert into A values(4,'D');
insert into A values(5,'E');
insert into A values(6,'F');
mysql> select * from A;
+----+------+
| id | name |
+----+------+
| 1 | A |
| 2 | B |
| 3 | C |
| 4 | D |
| 5 | E |
| 6 | F |
+----+------+
6 rows in set (0.00 sec)
现在要求用一条语句达到如下效果:
mysql> select * from B;
+----+------+---------------------+
| id | name | bak_time |
+----+------+---------------------+
| 1 | A | 2007-08-24 17:34:36 |
| 2 | B | 2007-08-24 17:34:36 |
| 3 | C | 2007-08-24 17:34:36 |
| 4 | D | 2007-08-24 17:34:36 |
| 5 | E | 2007-08-24 17:34:36 |
| 6 | F | 2007-08-24 17:34:36 |
+----+------+---------------------+
6 rows in set (0.00 sec)
PS: 可能是用MYSQL中的 create ....select ...但刚试了半天没弄出来,求高手指教,不胜感激!
[此贴子已经被作者于2007-8-24 18:18:56编辑过]