技术交流群:233513714 第一种方法: SELECT * FROM pay_inf_config a WHERE a.id IN ( SELECT REPLACE ( concat('''', s.pay_id, ''''), ',', ''',''' ) FROM sys_app s WHERE s.app_id ) 第二种方法: SELECT * FROM pay_inf_config a WHERE a.id IN ( SELECT '''' + REPLACE ( group_co…
--游标遍历某个字段 (打印出来) declare            res_sql varchar2(2000); cursor cur is            select f_dcname from W_EC_PLACESTATION_COLLECT t            where f_collectdate >= TRUNC(TO_DATE('2018-09-01','yyyy-MM-dd'),'month') AND f_collectdate < TO_DATE('2…
--sql中根据逗号分隔,查出多行数据 select       a.DiscussID,b.LocationID  from       (select DiscussID,LocationID=convert(xml,' <root> <v>'+replace(LocationID,',',' </v> <v>')+' </v> </root>') from SG_Discuss)a  outer apply      (sele…
echo "Cfoo'barxml" | sed "s/'/::/g" |  sed 's/::/\\:/g' |  sed "s/:/'/g"    替换单引号为 \' ------------------------ sed 替换单引号' echo "mmm'sss" > testcat test 把test内容中单引号替换成双引号sed 's/'"'"/'"''/g' test  ==…
在应用程序开发中,多条件查询是个经常遇到的情况,最简单最麻烦的方法是把所有的可能情况都考虑到,但是无疑是繁琐的,而且很容易漏掉可能的情形,下面是SQL语句实现多条件查询的情况 select * from table where table .a=case when isnull(a,'')!='' then a else table .a end and table .b=case when isnull(b,'')!='' then b else table .b end and table…
1.REPLACE 语法:REPLACE(char, search_string,replacement_string) 用法:将char中的字符串search_string全部转换为字符串replacement_string.       举例:SQL> select REPLACE('fgsgswsgs', 'fk' ,'j') 返回值 from dual;            返回值            ---------            fgsgswsgs SQL> sele…
1.对于CROSS APPLY 和 OUTER APPLY 的应用: CROSS APPLY 类似于INNER JOIN 但是,可以规定对于满足条件的数据需要关联几行,应用场景: 每个零件把第一个工单关联出来: OUTER APPLY 类似于LEFT JOIN ,不同之处同上: --inner join SELECT a.part_no,b.workorder FROM dbo.sys_part a INNER JOIN dbo.g_workorder_detail b ON a.part_id…
一.SQL中SUBSTRING函数的用法1.功能:返回字符.二进制.文本或图像表达式的一部分2.语法:SUBSTRING ( expression, start, length )3.QL 中的 substring 函数是用来抓出一个栏位数据中的其中一部分.这个函数的名称在不同的数据库中不完全一样:MySQL: SUBSTR(), SUBSTRING()Oracle: SUBSTR()SQL Server: SUBSTRING()4.参数:expression 字符串.二进制字符串.文本.图像.…
1.REPLACE 语法:REPLACE(char, search_string,replacement_string) 用法:将char中的字符串search_string全部转换为字符串replacement_string.       举例:SQL> select REPLACE('fgsgswsgs', 'fk' ,'j') 返回值 from dual;            返回值            ---------            fgsgswsgs SQL> sele…
--以scott用户下的dept和emp表为例 --注意:如果scott用户不能使用,请使用system用户登录--解锁scott用户ALTER USER SCOTT ACCOUNT UNLOCK;--重新设置密码 (identified 被识别的)alter user scott identified by tiger; --选择 所有字段 scott用户部门表SELECT * FROM scott.dept;--员工表SELECT * FROM scott.emp; --SELECT{*,…