SQL中取字段怎么个取法啊?

来源:百度知道 编辑:UC知道 时间:2024/04/30 00:03:22
比如说,我现在从A表中取出所有“月份”“班组”字段的值等于B表中“月份”“班组”的值的记录,并排列在B表中,该怎么写这个语句呢?
现在问题是,A中全部都是记录,而B单是查询单,查询条件为“月份”=N,“班组”=M,查询后所显示的记录是要达到这个要求的所有记录。

select B.班组,B.月份 from A,B where A.班组 = B.班组 and
A.月份 = B.月份

--------
是这个意思么

insert into B(月份,班组)
values(
select A.月份,A.班组
from A,B
where A.月份=B.月份 and A.班组=B.班组
)

insert into b
select A.* from a
join B
where a.月份=B.月份
AND A.班组=B.班组

select B.班组,B.月份 from A,B where A.班组 = B.班组 and
A.月份 = B.月份 and A.班组='M' and a.月份='N'