substring sql
来源:百度知道 编辑:UC知道 时间:2024/06/18 04:35:52
有俩张表t1,t2
t1里有字段zi
t2里有字段zi
|t1| |t2|
|zi | |zi |
|acxss | |123acxss |
|asda | |123asda |
|aad | |123aads |
现在要查t1.zi值等于t2.zi的值去除‘123’后相等的!
t1里有字段zi
t2里有字段zi
|t1| |t2|
|zi | |zi |
|acxss | |123acxss |
|asda | |123asda |
|aad | |123aads |
现在要查t1.zi值等于t2.zi的值去除‘123’后相等的!
select a.*,b.* from t1 a inner join t2 b on a.zj=stuff(b.zj,1,3,'') where left(zj,3)='123'
select a.*,b.* from t1 a inner join t2 b on a.zj=right(b.zj,len(zj)-3) where left(zj,3)='123'
楼上说的很对啊,不过你要对这个方法熟练还需多运用。可以看一下:SQL使用substring分割字符串的新经验,对两个字段进行分割后再拼凑。http://jingyan.baidu.com/article/aa6a2c142f1f750d4d19c456.html
select zi from t1 where zi in (select substring(zi,4,4)from t2)
substring(str,x,y): 由<str>中的第x位置开始,选出接下去的y个字元。
SQL中SUBSTRING ( expression , start , length ) ,如何使用的
substring的问题
C# substring问题
C#中substring 的用法
javaScript 里面 的subString 函数
substring和slice的区别
c#里的Substring()怎么不支持中文?
如何运用String.Substring(string.length-1)
javascript 中字符串函数substring的意义
SQL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!