I have created a procedure in mysql,but I can select nothing through the procedure,what's wrong with it?
我在mysql中创建了一个程序,但是我可以通过程序选择什么,它有什么问题?
delimiter //create procedure getLineStasticFreightList(in start int(4),in row int(4),in stationIDD varchar(4),in dateStart datetime,in dateEnd datetime)BEGINDROP VIEW IF EXISTS rqusg_lineStasticFreightUser;CREATE VIEW rqusg_lineStasticFreightUser AS SELECT a.id, c.stationName as station,b.name as track,sum(a.dddwTime) AS zgdddwsj, sum(a.ddzxTime) AS zgddzxsj, sum(a.zxzyTime) AS zgzxzysj, sum(a.ddzngyTime) AS zgddzngysj, sum(a.hcddqsTime) AS zgddqssjFROM rqusg_line_yard a join rqusg_line_tracks b on a.track = b.id join rqusg_line_stations c on a.stationID = c.stationIDWHERE a.stationID = 'stationIDD' and a.arriveTime >= 'dateStart' and a.clczTime <= 'dateEnd'group by a.trackunionselect a.id,c.stationName as station,b.name as track,sum(a.dddwTime) as zgdddwsj,sum(a.ddzxTime) as zgddzxsj,sum(a.zxzyTime) as zgzxzysj,sum(a.ddzngyTime) as zgddzngysj,sum(a.hcddqsTime) as zgddqssjfrom rqusg_line_yard a join rqusg_line_tracks b on a.track = b.id join rqusg_line_stations c on a.stationID = c.stationIDWHERE a.stationID = 'stationIDD' and a.arriveTime >= 'dateStart' and a.clczTime <= 'dateEnd'group by a.track;select * from rqusg_lineStasticFreightUser LIMIT start,row;END//
in my procedure,I create a view and select details from the view,but I can select nothing.I think there are something wrong in the params,but I am not sure.Can some one help me?
在我的程序中,我创建了一个视图并从视图中选择了详细信息,但我可以选择任何内容。我认为参数中有问题,但我不确定。可以帮助我吗?
2 个解决方案
#1
0
You should not put quotes around the parameter variables:
你不应该在参数变量周围加上引号:
WHERE a.stationID = stationIDD and a.arriveTime >= dateStart and a.clczTime <= dateEnd
By the way, both subqueries in your UNION are identical. Why do you have the same query twice?
顺便说一下,你的UNION中的两个子查询都是相同的。为什么两次有相同的查询?
#2
0
You may get error at this line WHERE a.stationID = 'stationIDD' and a.arriveTime >= 'dateStart' and a.clczTime <= 'dateEnd'
because you are putting single quotes arround variable which converts it to constant string and not variable.So change it to
你可能会在这一行得到错误WHERE a.stationID ='stationIDD'和a.arriveTime> ='dateStart'和a.clczTime <='dateEnd'因为你把单引号arround变量转换为常量字符串而不是变量。所以改成它
`WHERE a.stationID = stationIDD and a.arriveTime >= dateStart and a.clczTime <=dateEnd`
#1
0
You should not put quotes around the parameter variables:
你不应该在参数变量周围加上引号:
WHERE a.stationID = stationIDD and a.arriveTime >= dateStart and a.clczTime <= dateEnd
By the way, both subqueries in your UNION are identical. Why do you have the same query twice?
顺便说一下,你的UNION中的两个子查询都是相同的。为什么两次有相同的查询?
#2
0
You may get error at this line WHERE a.stationID = 'stationIDD' and a.arriveTime >= 'dateStart' and a.clczTime <= 'dateEnd'
because you are putting single quotes arround variable which converts it to constant string and not variable.So change it to
你可能会在这一行得到错误WHERE a.stationID ='stationIDD'和a.arriveTime> ='dateStart'和a.clczTime <='dateEnd'因为你把单引号arround变量转换为常量字符串而不是变量。所以改成它
`WHERE a.stationID = stationIDD and a.arriveTime >= dateStart and a.clczTime <=dateEnd`