美文网首页
一些方法

一些方法

作者: wppeng | 来源:发表于2018-03-05 14:08 被阅读0次

js中换行标签替换成\n

zgremark = zgremark.replace(/<br\s*/?>/gi, '\n');

合并多行查询数据到一行:使用自连接、FOR XML PATH('')、STUFF或REPLACE函数

select id,
[val]=( SELECT [value] +','
FROM tb AS b
WHERE b.id = a.id
FOR XML PATH('') )
FROM tb AS a

SUBSTRING(expression,start,length)
参数
expression
是字符串、二进制字符串、text、image、列或包含列的抒发型。不要施用包含聚合函数的抒发型。
start
是一个整数,指定子串的起头位置。
length
是一个整数,指定子串的长度(要返回的字符数或字节数)。

js生成随机数

//生成GUID
function guid() {
return 'xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};

js禁止鼠标右键

//禁止鼠标右键菜单 20160420
function stop() {
return false;
}
document.oncontextmenu = stop; //禁用鼠标右键
document.ondragstart = stop; //禁止拖动
document.onselectstart = stop; //禁止选择

SQL中EXISTS的用法

EXISTS子句可以用if(){}else(){}判断
EXISTS用于检查子查询是否至少会返回一行数据,该子查询实际上并不返回任何数据,而是返回值True或False
EXISTS 指定一个子查询,检测 行 的存在。
例子:
begin
IF EXISTS(select * from OPM3_App_Menu_User where usercode='00000000')
update OPM3_App_Menu_User set menuid='1,2,3' where usercode='00000000'
else
insert into OPM3_App_Menu_User(usercode,menuid) values('00000000','1,2,3,4,5,6,7')
end

sql把逗号隔开的字符串变成数据表charindex

select b.v_dlid,a.v_xm from pt_yhmc as a
inner join pt_login as b on a.v_yhdm=b.v_yhdm
where (charindex(a.v_xm,'龙博威,张瑞瑞,黄龙龙,王鹏,管理员,李雷,杨幂,韩红')<>0)

sql语句FOR XML PATH('')和charindex结合使用

select
(select v_xm+',' from pt_yhmc as b
where (charindex(b.v_yhdm,(select a.monitor from OPM_EPCM_IntendanceMaster as a where a.intendanceguid='7B62C515-CBEE-4F0A-9E00-053342F2FB70'))<>0)
for xml path(''))as viewuser,a.monitor,* from OPM_EPCM_IntendanceMaster as a where a.intendanceguid='7B62C515-CBEE-4F0A-9E00-053342F2FB70'
例子(表结构):
select a.intendanceguid,
(select v_xm+',' from pt_yhmc as b
where (charindex(b.v_yhdm,(select a.monitor from OPM_EPCM_IntendanceMaster as f where
f.intendanceguid=a.intendanceguid))<>0)
for xml path(''))as monitor,
a.monitor,* from OPM_EPCM_IntendanceMaster as a

sql语句通配符

QQ图片20170419160445.png

相关文章

  • 一些方法

    js中换行标签替换成\n zgremark = zgremark.replace(/ /gi, '\n'); 合并...

  • 一些方法

    http://unidal.org/cat/r/home?domain=cat&ip=All&date=20160...

  • OC协议

    协议:Protocol 它可以声明一些必须实现的方法和选择实现的方法 作用:用来声明一些方法 由一些列的方法声明组...

  • ios利用runTime进行方法交换-Method Swizzl

    利用oc运行时特性,进行方法交换,一般是把一些类方法交换成我们自己的方法,或者修改一些SDK的一些方法等.meth...

  • 对象

    拥有一些属性拥有一些方法的这样一个集合 创建对象 属性和方法 增加属性和方法 修改属性和方法 删除属性和方法 ob...

  • JS中函数的bind、call、apply总结

    如图,js函数本身就具有一些方法和属性 下面介绍一些常用方法。 1.bind方法 bind方法可以改变函数在被执行...

  • 一些方法收集

    /** * 判断是否在当前主线程 * @return */ public static boolean isOnM...

  • JS一些方法

    背景 在继续学习百度IFE课程时,遇见一些常用的方法,特此记录 toFixed() 可把Number四舍五入为指定...

  • 一些常用方法

    排序 根据对象某一int类型属性排序 注意compare比较NSNumber对象,使用@()封装Int类型注意一个...

  • 分享一些方法

    一、经典的麦肯锡工具 MECE 使用"MECE"就是分解结构,将问题细分为明确的无重叠的子问题。 针对问题大胆假设...

网友评论

      本文标题:一些方法

      本文链接:https://www.haomeiwen.com/subject/fcibattx.html