select afirst,blast from A as a join B as b where 1
想排序 就加上order by 条件(1)启动Microsoft SQL Server Management Studio程序 (2)按提示 *** 作进入系统 (3)选择那个建好表的数据库 (4)点击鼠标右键,会d出一个菜单,选择菜单命令:任务/导出数据无论你的数据如何动态只要你按照这种数据连接的方法都可以随时得到你想要的结果。
select DISTINCT aclass_id ,bClasses lj 这里写出你想要的任何一个表的列名,注意:a 表和 b 表的列需要加前辍 From 25175_num_note a inner join 25175_Exa b on aclass_id = bclass_id
如果需要条件可以在后面直接加
where aclass_id = '32' and bClasses lj <> ""经测试课使用,把数据存进临时表,再从临时表中读取数据 。A为你的数据表
CREATE table #temp
(
product_id NCHAR(10),
charge_id nchar(10),
[user_id] nchar(10) )
declare @p_id nchar(10),@c_id nchar(10),@u_id nchar(10)
declare id_cursor cursor for
select from A
open id_cursor
fetch from id_cursor
into @p_id ,@c_id,@u_id
while @@fetch_status=0
begin
if not exists( select from #temp where product_id=@p_id and charge_id=@c_id ) insert into #temp (product_id ,charge_id ,[user_id] )values(@p_id,@c_id,@u_id);
fetch next from id_cursor
into @p_id,@c_id,@u_id
end
close id_cursor
deallocate id_cursor
select from #temp
Goselect
ccid,
ccname as stdname,
ddname as contact_name,
ddtcl
from CC
left join
(
select
aaid,
aaname,
bbtel
from (select id,max(name) as name from B group by id) aa
left join B bb on aaid=bbid and aaname=bbname
) dd
on ccid=ddid
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)