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

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";
...全文
33 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
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'--;

34,575

社区成员

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

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