SQL查询问题. [英] problem with sql query..

查看:90
本文介绍了SQL查询问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此查询对我来说很好..

this query works fine for me..

tring query = "Select * from Products where ProductID in (''" + Request.QueryString["ID"].ToString().Substring(1) +"'') AND UnitCost < 5000";



但是当我修改它以添加更多信息时.该查询无法正常运行.休假查询有什么问题



but when i amend it to add some more information. the query doesnot works well. whats the problem with fallowing query

tring query = "Select * from Products where ProductID in (''" + Request.QueryString["ID"].ToString().Substring(1) +"'') AND UnitCost < 5000 or ProductID in (''" + Request.QueryString["ID"].ToString().Substring(1) +"'') AND UnitCost  5000 and 10000 ";

推荐答案

您很可能错过了括号和BETWEEN关键字.试试类似的东西:
Most likely you have missed parenthesis and the BETWEEN keyword. Try something like:
string query = "Select * from Products where (ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost < 5000) or (ProductID in ('" + Request.QueryString["ID"].ToString().Substring(1) +"') AND UnitCost BETWEEN 5000 and 10000)";


这篇关于SQL查询问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆