select distinct xxx,yyy from table得不到我想要的数据集

bushido 2003-08-20 10:58:37
select p.smallimg,p.id,p.name,p.prod_cd,p.marketprice,p.multi_pic from productsort c right outer join product p on p.productsort=c.id where c.fatherid=187 and p.smallimg in(select distinct smallimg from product) order by p.id desc
我测试过,不行,
当然只是用select distinct smallimg from product 是可以的

我又用
select distinct p.smallimg,p.id,p.name,p.prod_cd,p.marketprice,p.multi_pic from productsort c right outer join product p on p.productsort=c.id where c.fatherid=187 也不行

又加了group by还是不行



我的意思是
select distinct XXX from table当然是可以的
只是想一并取出其它字段时则不对
比如说
select distinct xxx,yyy from table就不对了
我改成 select xxx,yyy from table where xxx in(select distinct XXX from table)
竟然也不对。气坏了

help me




...全文
37 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bushido 2003-08-22
  • 打赏
  • 举报
回复
up
bushido 2003-08-21
  • 打赏
  • 举报
回复
to amtyuranus((看看))
能不能大概写段代码
bushido 2003-08-20
  • 打赏
  • 举报
回复
help
strongbear 2003-08-20
  • 打赏
  • 举报
回复
看不懂 productsort c 是啥东西? TABLE?应该挂号起来,中间有空格是不可以的吧。后面的也一样。

表名和字段名不规范,很容易混。不知道我的理解对不对?
amtyuranus 2003-08-20
  • 打赏
  • 举报
回复
你想要什么样啊 ?说了半天还是不清楚.不过大概知道了
select distinct xxx,yyy from table 当然可以了,只不过它要同时满足xxx,yyy都不同才是这样的效果

假如你要只要一个不同而别的都要可以显示,那你可以先用 select distinct XXX from table,做为子查询,然后根总表连接,
然后加上top 1 * 找出第一条来,而比别的就不显示了(既每个xxx只显示一条记录)

7,712

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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