zoukankan      html  css  js  c++  java
  • SSM项目中 SQL实现简单的连表查询

    • 需求分析:课程表(course)里有一个跟studet_id的字段,是对应student表里的id
    现在想要通过查询course表在根据课程表里的student_id查询到student表里的学生姓名name一并返回
    <select id="selectCourse" resultMap="BaseResultMap">
    select course.*,student.name
    from course,student
    where course.student_id = student.id
    and course.del_flag = 0
    order by id desc
    </select>

    也可用类似下面的语句:

    SELECT project_store.*,construction_unit.`name` from project_store

    INNER JOIN construction_unit ON project_store.constru_unit_id = construction_unit.id

    ORDER BY id DESC

    • 而且你需要在BaseResultMap原表基础上增加返回结果的字段:
    <result column="name" jdbcType="VARCHAR" property="studentName"/>
    • modal层也应该增加studentName字段
      private String studentName;
  • 相关阅读:
    linux 查看系统负载:uptime
    centos who命令 查看当前登录系统用户信息
    centos7 管理开机启动:systemd
    Linux ethtool 命令
    Linux ifconfig 命令
    linux centos7 目录
    POJ 1169
    POJ 1163
    POJ 1154
    POJ 1149
  • 原文地址:https://www.cnblogs.com/gslgb/p/13050575.html
Copyright © 2011-2022 走看看