永发信息网

sql语句查错

答案:3  悬赏:0  手机版
解决时间 2021-03-23 14:04
  • 提问者网友:却不属于对方
  • 2021-03-22 19:58
这是sql语句:

"SELECt qqid, title, sender, sendtime, overtime, jie, fatherID, topic, views, replys, MAX(b1) as best FROM (SELECt TOP 1000 q.ID as qqid, q.title, q.sender, q.sendtime, q.overtime, q.jie, q.fatherID, q.topic, q.views, q.replys, IIf(r.best=True,1,0) as b1 FROM oask_Reply r INNER JOIN oask_Question q ON r.qid = q.ID where replyer='" &User.UserName& "') v GROUP BY qqid, title, sender, sendtime, overtime, jie, fatherID, topic, views, replys"

执行后的sql

SELECt qqid, title, sender, sendtime, overtime, jie, fatherID, topic, views, replys, MAX(b1) as best FROM (SELECt TOP 1000 q.ID as qqid, q.title, q.sender, q.sendtime, q.overtime, q.jie, q.fatherID, q.topic, q.views, q.replys, IIf(r.best=True,1,0) as b1 FROM oask_Reply r INNER JOIN oask_Question q ON r.qid = q.ID where replyer='wangyong') v GROUP BY qqid, title, sender, sendtime, overtime, jie, fatherID, topic, views, replys

他提示我这里有错误,帮忙看下

服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: '=' 附近有语法错误。
最佳答案
  • 五星知识达人网友:佘樂
  • 2021-03-22 20:30
sql server 中用 case when

你不要用iif()

如果不会写case when 再发消息M我。
全部回答
  • 1楼网友:雾月
  • 2021-03-22 22:42
sql语句没有添加用户一说,但可以创建用户。 以oracle为例,创建用户的语法为: create user 用户名 identified by 密码;说明: 用户名应为英文字母(不区分大小写),密码则应为数字或字母(区分大小写)或英文字符或它们的组合。 在创建后需要给用户赋予一些权限,才可以使用,如: grant connect,resource,dba to 用户名;
  • 2楼网友:举杯邀酒敬孤独
  • 2021-03-22 22:04
试一下这个语句可以吗? SELECt qqid, title, sender, sendtime, overtime, jie, fatherID, topic, [views], replys, MAX(b1) as best FROM ( SELECt TOP 1000 q.[ID] as qqid, q.title, q.sender, q.sendtime, q.overtime, q.jie, q.fatherID, q.topic, q.[views], q.replys, (CASE WHEN r.best= true THEN 1 ELSE 0 END) as b1 FROM oask_Reply r INNER JOIN oask_Question q ON r.qid = q.[ID] where replyer ='') v GROUP BY qqid, title, sender, sendtime, overtime, jie, fatherID, topic,[views], replys
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯