sql语句,想用模糊查询,但子查询的结果有多个,请问如何写?

ytcgj 2008-01-01 01:02:03
例如select P_name from person where P_NAME like %(select name from spellcode where lowcase='z')% 这样的句子,

括号里子查询(select name from spellcode where lowcase='z')得到多个查询结果,如何对子查询的结果再对表person进行模糊查询,用select P_name from person where P_NAME in(select name from spellcode where lowcase='z') 不行,是精确查询,语法没错误,但得不到结果。select P_name from person where P_NAME like %(select name from spellcode where lowcase='z')% 语句报错误。请问各位,我这种需要怎么要怎么写。谢谢。


...全文
248 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fishmans 2008-03-28
  • 打赏
  • 举报
回复
同一楼
_码农一个_ 2008-01-03
  • 打赏
  • 举报
回复
select a.P_name from person a where a.P_NAME like (select '%' + b.name +'%' from spellcode b where b.lowcase='z')
  • 打赏
  • 举报
回复

select a.P_name from person a
where exists (select 1 from spellcode b where lowcase='z' and a.P_name like '%'+b.[name]+'%')

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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