INNER JOIN 鏈接兩個數據表的用法:
SELECT * FROM 表1 INNER JOIN 表2 ON 表1.字段號=表2.字段號sql
inner join(等值鏈接) 只返回兩個表中聯結字段相等的行 this
//從t1表的所有字段和t2表中 READ_FLAG,和LOOK_FLAG字段進行展現 List
SELECT
t1.*,
t2.READ_FLAG,
t2.LOOK_FLAG im
//從 表d_notice t1 和 表 d_notice_read_flag t2以條件 t1.row_id = t2.NOTICE_ID 進行查詢
FROM
d_notice t1
INNER JOIN d_notice_read_flag t2
ON t1.row_id = t2.NOTICE_ID
WHERE t1.ALERT_FLAG = 0
AND t1.USE_FLAG = 1
AND t1.DEL_FLAG = 0
AND t2.READ_FLAG = 0
AND t2.LOOK_FLAG = 0
AND t2.USER_ACCOUNT = ?
AND t1.START_TIME < ?
AND t1.END_TIME > ?
ORDER BY t1.TOP_FLAG DESC,
t1.CREATE_TIME DESC 數據
List<Map<String,Object>> findMapList = this.baseDao.findMapList(sql, userAccount, nowTime, nowTime);查詢