求助一条sql。大家帮忙看看。
时间:2011-11-07
来源:互联网
SELECT CODE FROM pro_sortinfo WHERE id IN (1,4)
SELECT id FROM pro_sortinfo WHERE CODE LIKE ''
下面的code要like上面那条语句查出来的code ,而上面那个code返回的是多个值。
用一条sql,请问各位大虾这条sql该如何写。
表结构
id code
1 001
2 001-001
3 001-002
4 002
5 002-001
SELECT id FROM pro_sortinfo WHERE CODE LIKE ''
下面的code要like上面那条语句查出来的code ,而上面那个code返回的是多个值。
用一条sql,请问各位大虾这条sql该如何写。
表结构
id code
1 001
2 001-001
3 001-002
4 002
5 002-001
作者: jeezz 发布时间: 2011-11-07
select a.*
from pro_sortinfo a,pro_sortinfo b
where b.id IN (1,4)
and a.code like concat(b.code,'%')
from pro_sortinfo a,pro_sortinfo b
where b.id IN (1,4)
and a.code like concat(b.code,'%')
作者: ACMAIN_CHM 发布时间: 2011-11-07
select a.*
from pro_sortinfo a,pro_sortinfo b
where b.id IN (1,4)
and instr(a.code ,b.code)=1
from pro_sortinfo a,pro_sortinfo b
where b.id IN (1,4)
and instr(a.code ,b.code)=1
作者: ACMAIN_CHM 发布时间: 2011-11-07
引用 2 楼 acmain_chm 的回复:
select a.*
from pro_sortinfo a,pro_sortinfo b
where b.id IN (1,4)
and instr(a.code ,b.code)=1
select a.*
from pro_sortinfo a,pro_sortinfo b
where b.id IN (1,4)
and instr(a.code ,b.code)=1
感谢。 能说说这2个的区别吗。bz。。
作者: jeezz 发布时间: 2011-11-07
INSTR(str,substr)
返回字符串 str 中子字符串的第一个出现位置
知道这个函数就应该明白了吧
返回字符串 str 中子字符串的第一个出现位置
知道这个函数就应该明白了吧
作者: zhaoyun0209 发布时间: 2011-11-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28