请问这句SQL有问题吗,为什么取不到数据

anan6676 2010-10-24 10:17:36
select distinct a.fundcode,a.fundnameabbr,a.pinyincode from tb_fundarchive a ,tb_fundnetvalue b where
a.isdeleted = 0 and a.fundtype = 7 and a.fundcode = b.fundcode
and (a.fundcode like '%021%' or a.pinyincode like '%021%' or a.fundname like '%021%' or a.fundnameabbr like '%021%')
...全文
76 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawugui 2010-10-25
  • 打赏
  • 举报
回复
从语法上未看出有什么错误,请确保是否存在数据?
select distinct a.fundcode,a.fundnameabbr,a.pinyincode 
from tb_fundarchive a ,tb_fundnetvalue b
where a.isdeleted = 0 and a.fundtype = 7 and a.fundcode = b.fundcode
and (a.fundcode like '%021%' or a.pinyincode like '%021%' or a.fundname like '%021%' or a.fundnameabbr like '%021%')
claro 2010-10-24
  • 打赏
  • 举报
回复
是否没有所需数据。
「已注销」 2010-10-24
  • 打赏
  • 举报
回复
有可能出现这样的情况。
加上distinct应该是可以的,mysql确实没用过。不太了解。
Snashy 2010-10-24
  • 打赏
  • 举报
回复
刚接触到T-Sql ,看到这里用到了distinct,所以想问一下,是不是有这种可能:比如:表1和表2 利用内部连接,有可能返回两行完全一样的数据?包括惟一标识都一样?
前两天我就遇到了这个问题,
还望能指教一下!在此谢了!
「已注销」 2010-10-24
  • 打赏
  • 举报
回复
查了下,好像这样的写法没有问题。
「已注销」 2010-10-24
  • 打赏
  • 举报
回复

mysql?
不会!
anan6676 2010-10-24
  • 打赏
  • 举报
回复
mysql的这样也可以写的吧?
「已注销」 2010-10-24
  • 打赏
  • 举报
回复
看上去没什么问题,可以分段进行查询,看看问题到底出在哪儿。

select distinct a.fundcode,a.fundnameabbr,a.pinyincode 
from tb_fundarchive a ,tb_fundnetvalue b
where a.isdeleted = 0 and a.fundtype = 7
and a.fundcode = b.fundcode---注意内连接要有符合的条件,否则就查不到数据。
and (a.fundcode like '%021%' or a.pinyincode like '%021%'
or a.fundname like '%021%' or a.fundnameabbr like '%021%')

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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