SQL联表更新,联表查询
没有引用关系的表
1. 联表更新
update a set a.education = '本科' from NT_UserInfo a ,NT_User b where a.UserID=b.UserID and b.email = 'carlfan2008@163.com'
2. 联表查询
select a.*,b.* from nt_user as a, nt_userinfo as b where a.userid = b.userid and Email = 'carlfan2008@163.com'
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
YearCode:=yearof(Date);
MonthCode:=monthof(Date);
if MonthCode>9 then
FTime1:=inttostr(YearCode)+inttostr(MonthCode)
else
&nb ......
Transact-SQL 提供了(BEGIN...END、BREAK、GOTO、CONTINUE、IF...ELSE、WHILE、RETURN、WAITFOR)控制流关键字,用于控制 Transact-SQL 语句、语句块、用户定义函数以及存储过程的执行流。 不使用控制流语言,则各 Transact-SQL 语句按其出现的顺序分别执行。控制流语言使用与程序设计相似的构造使语句得以互相连接、关联和 ......
Oracle中的递归查询可以依靠增强的sql语句START WITH ...CONNECT BY PRIOR来搞定.sql 2005中不支持该语句,以下示例可以实现递归查询.
WITH TREE(xzdm,Prexzdm,lvl,topxzdm)
AS
(
SELECT xzdm,prexzdm,1,prexzdm as topxzdm from xzdm WHERE Prexzdm = '000000000000'
&nbs ......
交叉表语句的实现:
用于:交叉表的列数是确定的
select name,sum(case subject when '数学' then source else 0 end) as '数学',
sum(case subject when '英语' then source else 0 end) as '英语',
sum(case subject when '语文' then source else 0 end) as '语文'
from test
group by name ......