注册 登录
编程论坛 MySQL论坛

sql中添加参数方法

tianbian210 发布于 2013-03-08 17:15, 2166 次点击
使用reporting service开发报表,
mysql数据源时问题。
需要在sql中添加几个参数,请大神协助:
select p.name as projectname,
       b.id,
       g.name categoryname,
       u.realname,
       b.summary,
       t.description,
       c.depart,
       c.owner,
       c.descrip,
       (case b.status
         when '10' then
          '新建'
         when '40' then
          '已确认'
         when '50' then
          '已分派'
         when '80' then
          '已解决'
         when '85' then
          '已验收'
         when '90' then
          '已关闭'
         else
          '其他'
       end) as status,
       FROM_UNIXTIME(b.date_submitted) as starttime,
       FROM_UNIXTIME(b.last_updated) as endtime
  from mantis_bug_table b,
       mantis_bug_text_table t,
       mantis_project_table p,
       mantis_category_table g,
       mantis_user_table u,
       (select a1.bug_id, a1.depart, a2.owner, a3.descrip
          from (select bug_id, value as depart
                  from mantis_custom_field_string_table
                 where field_id = '1') a1
          LEFT JOIN (select bug_id, value as owner
                      from mantis_custom_field_string_table
                     where field_id = '4') a2
            on a2.bug_id = a1.bug_id
          LEFT JOIN (select bug_id, value as descrip
                      from mantis_custom_field_string_table
                     where field_id = '7') a3
            on a3.bug_id = a2.bug_id) c
 where b.bug_text_id = t.id
   and b.project_id = p.id
   and b.id = c.bug_id
   and b.category_id = g.id
   and b.reporter_id = u.id
AND p.name like @proname || '%'
AND b.status  like @status || '%'


试过了@ + 参数名;$ +参数名。都没用。
哪位知道的帮忙看下。
2 回复
#2
亲丶5202013-05-17 22:35
使用表了没
#3
java小蚂蚁2013-08-10 23:46
直接加不行吗?一定呀加@这些?。或者你流个?在哪里,然后在其他地方不上。用占位符?来搞定,看行不
1