使用mysql limit时问题(在线等)
select * from jsp_ttt where jsp_forum= '3 ' limit 0,50
当select 中没有数据使用limit就会出错,怎么解决?
------解决方案--------------------先判断select中是否有值
if exists( select * from jsp_ttt where jsp_forum= "3 " )
begin
select * from jsp_ttt where jsp_forum= "3 " limit 0,50
end
else
begin
print 'select中没有值'
end
------解决方案--------------------1\
select * from jsp_ttt where jsp_forum= "3 " limit 0,50
---------------
我看好象没有问题,你在Front工具里调试一下,看报什么错.
2\
----------------------------------------------
先判断select中是否有值
if exists( select * from jsp_ttt where jsp_forum= "3 " )
begin
select * from jsp_ttt where jsp_forum= "3 " limit 0,50
end
else
begin
print 'select中没有值 '
end
----------------------------------------------
不需要这么做,limit实际上在MySQL中相当于SQL中的TOP,所以.......
------解决方案--------------------可以用isnull(( select * from jsp_ttt where jsp_forum= "3 " limit 0,50 ),'空')
------解决方案--------------------你的mysql 3以前的?