试试,是你想要的么? Select 编号,名称,数量,旧点数,(新数量-旧数量) as 数量相差,省市,地址 From 记录 ,通讯管理 where 状态=''未结'' and 客户编号=1001
Select 编号,名称,数量,旧点数,(新数量-旧数量) as 数量相差,省市,地址,公司名称 From 记录 j,通讯管理 t where 状态=''未结'' and j.客户编号=1001 and j.客户编号 = t.客户编号 是不是你要的?
数据没有关联,取出来有什么用? Select a.编号,a.名称,a.数量,a.旧点数,(新数量-旧数量) as 数量相差 ,b.省市,b.地址,b.公司名称 where From 记录 as a,通讯管理 as b where a.状态=''未结'' and a.客户编号=1001 and b.客户编号=1001
--try :结果不同 --1 其实有关联关系 Select a.编号,a.名称,a.数量,a.旧点数,(a.新数量-a.旧数量) as 数量相差 ,b.省市,b.地址,b.公司名称 From 记录 a join 通讯管理 b on a.客户编号 = b.客户编号 where a.状态='未结' and b.客户编号=1001--2 没有关联关系 with tbl as ( Select 编号,名称,数量,旧点数,(新数量-旧数量) as 数量相差,''省市,''地址,''公司名称 From 记录 where 状态='未结' and 客户编号=1001 UNION ALL Select ''编号,''名称,''数量,''旧点数,''数量相差,省市,地址,公司名称 From 通讯管理 where 客户编号=1001 ) select * from tbl
Select 编号,名称,数量,旧点数,(新数量-旧数量) as 数量相差,省市,地址
From 记录 ,通讯管理
where 状态=''未结''
and 客户编号=1001
Select 编号,名称,数量,旧点数,(新数量-旧数量) as 数量相差,省市,地址,公司名称 From 记录 j,通讯管理 t
where 状态=''未结'' and j.客户编号=1001 and j.客户编号 = t.客户编号
是不是你要的?
Select a.编号,a.名称,a.数量,a.旧点数,(新数量-旧数量) as 数量相差 ,b.省市,b.地址,b.公司名称 where From 记录 as a,通讯管理 as b where a.状态=''未结'' and a.客户编号=1001 and b.客户编号=1001
--1 其实有关联关系
Select a.编号,a.名称,a.数量,a.旧点数,(a.新数量-a.旧数量) as 数量相差
,b.省市,b.地址,b.公司名称
From 记录 a
join 通讯管理 b on a.客户编号 = b.客户编号
where a.状态='未结' and b.客户编号=1001--2 没有关联关系
with tbl as (
Select 编号,名称,数量,旧点数,(新数量-旧数量) as 数量相差,''省市,''地址,''公司名称
From 记录 where 状态='未结' and 客户编号=1001
UNION ALL
Select ''编号,''名称,''数量,''旧点数,''数量相差,省市,地址,公司名称
From 通讯管理 where 客户编号=1001
)
select * from tbl
第二表构造出与第一表列相同,然后用union all合并了。