SQL存储过程问题!请高手帮忙!大伙来看看!顶着有分不够+分!
autoPrice数据表名
@jiage变量
程序一运行传入一个价格的参数
然后查找!
select * from autoPrice where @jiage > 5 and @jiage <5
比方说现在传入的是30那就在数据库查找35-25之间的所有数据!
select * from autoPrice where 30 > 5 and 30 <5
我这样写对吗?请高手给我看看纠正!
------解决方案--------------------filedname > @jiage-5 and fieldname <@jiage+5
fieldname 代表价格对应的特定的字段
------解决方案--------------------对的
存储过程应该是这样..
create proc test
(
@jiage int
)
as
select * from autoPrice where @jiage > 5 and @jiage <5
------解决方案--------------------select * from autoPrice where @jiage > 5 and @jiage <5
没有既大于5又小于5的价格,这个数值肯定不存在,楼主思路正确,但是语法有错误。
------解决方案--------------------up
------解决方案--------------------CREATE PROCEDURE yourProcedureName
@JiaGe int
AS
SET NOCOUNT ON
SELECT * FROM autoPrice
WHERE yourPriceField between @JiaGe-5 and @JiaGe+5
Go
------解决方案--------------------create proc test
(
@jiage float
)
as
select * from Price where Price.jiage> @jiage-5 and Price.jiage <@jiage +5