select into语句的问题

来源:百度知道 编辑:UC知道 时间:2024/09/20 14:42:51
use pubs

create table b
(
u_id char(20) primary key
)

select * into b from authors where au_lname like '%e%'

select * from b
请问上面代码有错误吗?
如果没有,为什么表b中没有被插入数据呢?
请高手帮忙解决,小弟不是很懂into语句的使用!!!

当然有问题啊 列数都对不上 怎么可能没有错误呢 不能用星号 指定列名 至少列是对应的 然后还要确认取出来的值类型一样或者这两种类型是可以直接转换的

select authorid into b from authors where au_lname like '%e%'

select * into b from authors where au_lname like '%e%'
是代表表b不存在的情况下把数据放到表中,并自动建表b
所以你那句该改成
insert into b select * from authors where au_lname like '%e%'