zoukankan      html  css  js  c++  java
  • sql

    mysql>-- 笛卡尔积查询,无连接条件查询
    mysql>select a.*,b.* from customers a , orders b ;

    mysql>-- 内连接,查询符合条件的记录.
    mysql>select a.*,b.* from customers a , orders b where a.id = b.cid ;

    mysql>-- 左外连接,查询符合条件的记录.
    mysql>select a.*,b.* from customers a left outer join orders b on a.id = b.cid ;

    mysql>-- 右外连接,查询符合条件的记录.
    mysql>select a.*,b.* from customers a right outer join orders b on a.id = b.cid ;

    mysql>-- 全外连接,查询符合条件的记录(mysql不支持全外链接)
    mysql>select a.*,b.* from customers a full outer join orders b on a.id = b.cid ;

    oracle中字符串的截取获取:

    获取类似“12R22.5国产无内胎”字符串中所有a-z和数字的值

    select a.vin , translate(a.tires_type,
    '#' || translate(a.tires_type,
    'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.',
    '#'),
    '/') tires_type
    from T_V_AXLE_INFO a

    字符串截取

    以使用instr函数对某个字符串进行判断,判断其是否含有指定的字符。 

    在一个字符串中查找指定的字符,返回被查找到的指定的字符的位置。 

    语法: 

    例子

    SELECT
    SUBSTR (gearbox_type,1,INSTR (gearbox_type, '-',1)-1) AS STF_NAME
    FROM
    T_V_AXLE_INFO
    instr(sourceString,destString,start,appearPosition) 

    instr('源字符串' , '目标字符串' ,'开始位置','第几次出现') 

    其中sourceString代表源字符串; 

    destString代表要从源字符串中查找的子串; 

    start代表查找的开始位置,这个参数可选的,默认为1; 

    appearPosition代表想从源字符中查找出第几次出现的destString,这个参数也是可选的, 默认为1 

    如果start的值为负数,则代表从右往左进行查找,但是位置数据仍然从左向右计算。 

    返回值为:查找到的字符串的位置。

  • 相关阅读:
    搭建Java环境
    【leetcode】257. 二叉树的所有路径
    【leetcode】563. 二叉树的坡度
    【leetcode】401. 二进制手表
    【leetcode】859. 亲密字符串
    【leetcode】1441. 用栈操作构建数组
    【leetcode】1502. 判断能否形成等差数列
    【leetcode】605. 种花问题
    【leetcode】1252. 奇数值单元格的数目
    【leetcode】1640. 能否连接形成数组
  • 原文地址:https://www.cnblogs.com/zyanrong/p/10766004.html
Copyright © 2011-2022 走看看