sql2005数据库 合成表
来源:百度知道 编辑:UC知道 时间:2024/06/07 17:37:12
我的具体问题是这样的:source表中有准考证号,姓名等其他数据,reported表只中有准考证号数据,现在想生成charge表,跟source表结构一样,数据由reported表的准考证号和source表中该准考证号的其他数据一起组成...
说具体点,谢谢...
弱弱的问下,那些语句要在哪里写啊???因为我之前都是界面设计或者导入数据库的,还没有代码生成过...
说具体点,谢谢...
弱弱的问下,那些语句要在哪里写啊???因为我之前都是界面设计或者导入数据库的,还没有代码生成过...
insert into charge select reported.准考证号, source.姓名 from reported join source on reported.准考证号=source.准考证号
select a.*,b.准考证号 into charge from source a inner join reporte b on a.准考证号=b.准考证号
select * from charge
直接用SELECT INTO 语法创建新的表
SELECT *
INTO reportedANDsource
FROM (
SELECT *
FROM reported JOIN source
ON reported.准考证号=source.准考证号
) AS T
然后再去删除一列就行了
select * into charge
from (select source.准考证号,姓名,……
from source,reported
where source.准考证号=reported.准考证号)