baidu_29643173 2015-09-11 06:48 采纳率: 0%
浏览 2220

用户名称(登录人)查询,但是我这个表里存的是user表里的id,而不是名

下边是我实现图片功能的代码:现在我需要添加一个用户名称(登录人)查询,但是我这个表里存的是user表里的id,而不是名称,所以我想知道怎么实现按名称查询,求大神能够在代码上修改,大家可以先看看我的代码,或者详细告知下,本人新手,跪求指导

图片说明

    public String getList() throws Exception
    {


         chengJiJiLuList = dao.getList(TrainingOrCompetitionID,startTime,endTime);


          userList = this.getUserLisAll();
         return SUCCESS;
    }

    public ArrayList getUserLisAll() throws Exception {
           Users user = new Users();
           ArrayList userList = new ArrayList<Users>();
           service.getObjList(userList, user, " oid in (select id from organization)", " id");
           return userList;
       }
 public List<ChengJiJiLu>   getList(int trainingOrCompetitionID,String startTime,String endTime)
    {
        String where = " ";
        where = where + " and " +  TypeChange.DateBetweenSql("a.shiJian", startTime, endTime)+ " and " +"TrainingOrCompetitionID="+trainingOrCompetitionID;
            return this.findAll(where);
    }
<div class="buttonDiv">
         查询日期: <input type="text" name="startTime" size="10" value="<s:property value="startTime"/>" readonly="true" onclick="setday(this)">
           至 <input type="text" name="endTime" size="10" value="<s:property value="endTime"/>"  readonly="true" onclick="setday(this)"> &nbsp;&nbsp;
        用户名称:<s:textfield name="keRenMingCheng" size="8" value="%{keRenMingCheng}"/>&nbsp;&nbsp;
        <s:submit theme="simple" name="List" action="List" value="查询" cssClass="button_style" method="getList"/> &nbsp;&nbsp;
         <input type="button" class="button_style_add" onclick="return doAction('add')"/>
         <input type="button" class="button_style_edit" onclick="return doAction('update')"/>
         <input type="button" class="button_style_del" onclick="return doAction('del')"/>
    </div>
    <div class="validatemsg">
        <s:actionerror/>
        <s:fielderror/>
        <s:actionmessage/>
    </div>



    <table width="100%" class="listext" id="table1">
      <tr>
            <TH colspan="7" style="background:  #EBEBEB;height: 35px"> 成绩记录</TH>
        </tr>

    <TR>
       <TH width="10"><s:checkbox id="doAllSele" value="" onclick="selectAll()" name="doAllSele"></s:checkbox></TH>
       <TH width="30"> 序号</TH>
       <TH>用户名称</TH>
       <%--<TH>TrainingOrCompetitionID</TH>--%>
       <TH>时间</TH>
       <TH>项目</TH>
       <TH>状态</TH>
       <TH>备注</TH>
    </TR>
<s:iterator value="chengJiJiLuList" status="st" var="cil">
    <TR>
       <TD><input type="checkbox" name="selId" id="selId" value="<s:property value="id"/>"/></TD>
       <TD  align="center"><s:property value='#st.index+1'/></TD>
       <TD ><s:iterator value="userList" var="ulist">
                                <s:if test="#ulist.id==#cil.userID"><s:property value="#ulist.name"/></s:if>
                            </s:iterator></TD>
       <%--<TD ><s:property value="trainingOrCompetitionID"/></TD>--%>
       <TD  align="center"><s:date name="shiJian" format="yyyy-MM-dd" /></TD>
       <TD ><s:property value="xiangMu"/></TD>
       <TD ><s:property value="zhuangTai"/></TD>
       <TD ><s:property value="beiZhu"/></TD>
    </TR>


</s:iterator>
</TABLE> 
  • 写回答

2条回答 默认 最新

  • IT丶小农民 2015-09-11 09:28
    关注

    select * 表A,表B where A.id = B.id and B.学生名称=? 。这样现实两张表关联根据学生名称查询你需要的结果集。

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办