mysql insert中使用select

来源:百度知道 编辑:UC知道 时间:2024/06/03 00:03:24
INSERT INTO
aa
(a, b, c, d, e, f, g, h)
VALUES
(
SELECT
id as a, title, c, d,
e, f, g, h
FROM
b
WHERE
id = 1
)

INSERT INTO
aa
(a, b, c, d, e, f, g, h)
SELECT
id as a, title, c, d,
e, f, g, h
FROM
b
WHERE
id = 1
注意:
readset writeset exceptset指定要让内核测试读、写和异常条件的描述字。如果对某一个的条件不感兴趣,就可以把它设为NULL。如果三个指针都为NULL,我们就有了一个比sleep()函数更为精确的定时器(sleep()以毫秒为最小单位,这个以微秒为单位)。
select使用描述字集,典型地是一个整数数组,其中每个整数中的每一位对应一个描述字。假设使用32位整数,那么该数组的第一个元素对应于描述字0~31,第二个元素对应于描述字32~63,依此类推。所有的实现细节都与应用程序无关,它们隐藏在名为fd_set的数据类型和以下四个宏中:
void FD_ZERO (fd_set *fdset); // clear all bits in fdset
void FD_SET (int fd,fd_set *fdset); // turn on the bit for fd in fdset
void FD_CLR (int fd,fd_set *fdset); // turn off the bit for fd in fdset
intFD_ISSET(int fd,fd_set *fdset); // is the bit for fd on in fdset

INSERT INTO
aa
(a, b, c, d, e, f, g, h)
SELECT
id as a, title, c, d,
e, f, g, h
FROM
b
WHERE
id = 1

这样子可以运行 就是 批量插入的意思 将B表符合条件的记录 插入到aa表中