sql 语句 两基本表个表和中间表的多表查询查询

select record.*,course.* from 7east_adminopencourse_record record ,7east_course course where record.courseid=course.cid







public List<Map> findStdCourseRecordTest(int uid, int type) {
		
		String sql = "select record.*,course.* from 7east_adminopencourse_record record ,7east_course course where record.courseid=course.cid and userid=? and type=?";
		Object[] args = new Object[] { uid, type };
		
		RowMapper argTypes = new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				Map map = new HashMap();
				
				String  cname = rs.getString("cname");
			
				map.put("cname", cname)	;
			
				return map;
			}
		};
		List<Map> list = getJdbcTemplate().query(sql, args,
				argTypes);
		return list;
            }

















select record.*,course.*,member.* from 7east_adminopencourse_record record ,7east_course 
course,uchome_member member where record.courseid=course.cid and userid=2 and uid=1;




select record.*,course.*,member.* from 7east_adminopencourse_record record ,7east_course 
course,uchome_member member where record.courseid=course.cid and userid=1 and member.uid=record.adminuserid;














public List<Map> findStdCourseRecordTest(int uid ) {
		
		String sql = "select record.*,course.*,member.* from 7east_adminopencourse_record record ,7east_course course,uchome_member member where record.courseid=course.cid and record.userid=? and member.uid=record.adminuserid";
		Object[] args = new Object[] { uid };
		
		RowMapper argTypes = new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				Map map = new HashMap();
				
				String  cname = rs.getString("cname");
				String  casetype = rs.getString("casetype");
				int  price = rs.getInt("price");
				int  createtime = rs.getInt("createtime");
				String  username = rs.getString("username");


				map.put("cname", cname)	;
				map.put("casetype", casetype)	;
				map.put("price", price)	;
				map.put("createtime", createtime)	;
				map.put("username", username)	;
				
				
				return map;
			}
		};
		List<Map> list = getJdbcTemplate().query(sql, args,
				argTypes);
		return list;
		
	}









你可能感兴趣的:(sql)