如何写关联表查询语句 select * from news left join newslb on news.sortid=newslb.id2 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 declare @news table(id1 int, title varchar(20),sortid int)declare @newslb table(id2 int,lbtitle varchar(20))insert @newsselect 1,'title1',1 unionselect 2,'title2',2 unionselect 3,'title3',1insert @newslb select 1,'sort1' union select 2,'sort2'select * from @news news left join @newslb newslb on news.sortid=newslb.id2--结果/*id1 title sortid id2 lbtitle ----------- -------------------- ----------- ----------- ---------1 title1 1 1 sort12 title2 2 2 sort23 title3 1 1 sort1(所影响的行数为 3 行)*/ select a.*,b.lbtitle from news a,newslb b where a.sortid = b.id2orselect a.*,b.lbtitle from news a inner join newslb b on a.sortid = b.id2 整站搜索存储过程 sql查询问题 列名 'year_old' 无效。 sqlserver 2000注册失败 求个存储过程的写法,急!!!!!!!! 为什么这个语句SELECT * FROM supervise_aviso where id in ('"+ss+"') order by senddate desc;会有语法错误,我搞不懂啦!! 自定义函数的简单问题 请教 运行下面的sql语句提示'00' 附近有语法错误。 查找非全为空列 为什么在SQL里面实现,但是在ACCESS实现不了? 求一sql語句 关于SQL身份验证问题
declare @newslb table(id2 int,lbtitle varchar(20))
insert @news
select 1,'title1',1 union
select 2,'title2',2 union
select 3,'title3',1insert @newslb
select 1,'sort1' union select 2,'sort2'select * from @news news left join @newslb newslb on news.sortid=newslb.id2--结果
/*
id1 title sortid id2 lbtitle
----------- -------------------- ----------- ----------- ---------
1 title1 1 1 sort1
2 title2 2 2 sort2
3 title3 1 1 sort1(所影响的行数为 3 行)
*/