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的值为负数,则代表从右往左进行查找,但是位置数据仍然从左向右计算。
返回值为:查找到的字符串的位置。