在 oracle,mysql 数据库中 求一sql

你们都是坏人 2016-08-05 11:17:44
页面上 传递过来的 参数,
如下:
AB12
CD32
EF11
AB10
这些参数 一次性传递。

是在 textarea 中输入的,即:输了AB12 回车 然后输入 CD32 ……
表 a
t_id t_name t_type
1 ABC AB12
2 BCD CD32
3 CDSF EF11
4 DSSF AB112
5 SDSF AB10
6 XSF EF11
……

求 一个sql 查询 出来 t_type in ('AB12''CD32','EF11','AB10',……)
的数据,分别是oracle 与 MySQL 资料库中。
谢谢!
...全文
109 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
你们都是坏人 2016-08-08
  • 打赏
  • 举报
回复
引用 5 楼 js14982 的回复:
[quote=引用 3 楼 xinhao_ 的回复:] [quote=引用 1 楼 ghx287524027 的回复:] oracle 中这样不行吗?不知道有没有理解错你的意思 select * from tablename where instr(inputstr,t_type)>0
oracle 中这样好像可以,应该没理解错!! thanks![/quote] 可是这样有点问题呀,比如你的传入是AB12345,你的 t_type是AB12,也是会匹配上的[/quote] 确实有这样的问题,先不考虑吧
js14982 2016-08-05
  • 打赏
  • 举报
回复
我都没听太明白 - - 页面传来的参数能不能放临时表里再来关联?
ghx287524027 2016-08-05
  • 打赏
  • 举报
回复
oracle 中这样不行吗?不知道有没有理解错你的意思 select * from tablename where instr(inputstr,t_type)>0
ghx287524027 2016-08-05
  • 打赏
  • 举报
回复
要是想完全匹配输入的话可以这么做

select * from tablename where t_type in
(select  regexp_substr('a,b,c,da'|| ',', '[^,]+', 1, level) name
from dual
connect by level <= regexp_count('a,b,c,da'|| ',', '[^,]+'))
其中,'a,b,c,da' 是你输入进来的字符串
ghx287524027 2016-08-05
  • 打赏
  • 举报
回复
引用 3 楼 xinhao_ 的回复:
[quote=引用 1 楼 ghx287524027 的回复:] oracle 中这样不行吗?不知道有没有理解错你的意思 select * from tablename where instr(inputstr,t_type)>0
oracle 中这样好像可以,应该没理解错!! thanks![/quote] mysql好像也能这么写,也有instr() 函数,可以测试一下
js14982 2016-08-05
  • 打赏
  • 举报
回复
引用 3 楼 xinhao_ 的回复:
[quote=引用 1 楼 ghx287524027 的回复:] oracle 中这样不行吗?不知道有没有理解错你的意思 select * from tablename where instr(inputstr,t_type)>0
oracle 中这样好像可以,应该没理解错!! thanks![/quote] 可是这样有点问题呀,比如你的传入是AB12345,你的 t_type是AB12,也是会匹配上的
你们都是坏人 2016-08-05
  • 打赏
  • 举报
回复
引用 2 楼 js14982 的回复:
我都没听太明白 - - 页面传来的参数能不能放临时表里再来关联?
不能,
你们都是坏人 2016-08-05
  • 打赏
  • 举报
回复
引用 1 楼 ghx287524027 的回复:
oracle 中这样不行吗?不知道有没有理解错你的意思 select * from tablename where instr(inputstr,t_type)>0
oracle 中这样好像可以,应该没理解错!! thanks!

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧