mysql动态拼接sql语句

begin

/**procedure body**/
if(m_parameter='') then
set @sqlStr=concat('select id,title,description,msg,logo,notice,views,grade,commenttimes from kmb01',' order by ',m_sort,' ',m_sortType,' limit ',m_index,',',m_length);
else
set @sqlStr=concat('select id,title,description,msg,logo,notice,views,grade,commenttimes from kmb01 where ',m_parameter,' order by ',m_sort,' ',m_sortType,' limit ',m_index,',',m_length);
end if;
PREPARE msql from @sqlStr;
EXECUTE msql;
end

posted @ 2015-03-10 11:19  Asilan  阅读(7519)  评论(0编辑  收藏  举报