这样的语句有错吗?谢谢!

liuvb 2004-05-05 01:59:54
sqlStr="select count(distinct a.shopnumber,a.shopname,a.bianhao,,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark) as myxdotnet from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' Order By a.bianhao desc";
...全文
9 13 点赞 打赏 收藏 举报
写回复
13 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zjcxc 元老 2004-05-05
sqlStr="select count(*) as myxdotnet from(select distinct a.shopnumber,a.shopname,a.bianhao,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' )a";
  • 打赏
  • 举报
回复
liuvb 2004-05-05
有点像 8992026(8992026) 的,我试了他的不行。
  • 打赏
  • 举报
回复
liuvb 2004-05-05
我想用myxdotnet
代表总记录数。

怎么myxdotnet加在你的语名中。谢谢!
  • 打赏
  • 举报
回复
zjcxc 元老 2004-05-05
--就是这个啊
sqlStr="select count(*) from(select distinct a.shopnumber,a.shopname,a.bianhao,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' )a";
  • 打赏
  • 举报
回复
liuvb 2004-05-05

我想用查询的总记录数myxdotnet, 放在上面的语句中应该怎么做。谢谢
  • 打赏
  • 举报
回复
liuvb 2004-05-05
多谢各位!
我先试一下
  • 打赏
  • 举报
回复
zjcxc 元老 2004-05-05
--上面还有个问题: order by ..多余
sqlStr="select count(*) from(select distinct a.shopnumber,a.shopname,a.bianhao,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' )a";
  • 打赏
  • 举报
回复
8992026 2004-05-05
可能错误多了,你要的结果到底是什么?
更正一下上面的:

sqlStr="select count(*) as myxdotnet from (select distinct a.shopnumber,a.shopname,a.bianhao,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' ) as x";


  • 打赏
  • 举报
回复
zjcxc 元老 2004-05-05
错误1:
a.bianhao,,a.fs --多了一个逗号

错误2:
count(distinct ..后面跟的字段太多),所以改子查询
  • 打赏
  • 举报
回复
8992026 2004-05-05
有错,两个逗号
count(distinct ...)只能一个字段

sqlStr="select count(*) as myxdotnet from (select distinct a.shopnumber,a.shopname,a.bianhao,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' )";
  • 打赏
  • 举报
回复
zjcxc 元老 2004-05-05
sqlStr="select count(*) from(select distinct a.shopnumber,a.shopname,a.bianhao,a.fs,a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%' and b.temp_number like '%"+product_name+"%' Order By a.bianhao desc)a";
  • 打赏
  • 举报
回复
internetcsdn 2004-05-05
语法通过,未知能否执行
  • 打赏
  • 举报
回复
internetcsdn 2004-05-05
declare @sqlstr varchar(1000)
select @sqlStr='select count(distinct a.shopnumber,a.shopname,a.bianhao,,a.fs,
a.money1,a.money2,a.giveok,a.givetime,a.outok,a.outtime,a.remark) as myxdotnet
from dangqi a,temporder b where a.bianhao=b.orderid and a.shopnumber like '%"+shop_number+"%'
and b.temp_number like '%"+product_name+"%' Order By a.bianhao desc'--;
  • 打赏
  • 举报
回复
相关推荐
发帖
MS-SQL Server
加入

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2004-05-05 01:59
社区公告
暂无公告