最好这样,join多表链接最好使用数字类型,且必须为主键,否则可能会链接失败
SELECT * FROM (
(
表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号
)
INNER JOIN 表3 ON 表1.字段号=表3.字段号
) INNER JOIN表4 ON Member.字段号=表4.字段号
例子
SELECT
a.owner_id,
a.owner_code,
a.owner_name,
a.owner_desc,
a.lat,
a.lng,
b.fid dictId,
c.fname dictName
FROM
(B_OWNER a INNER JOIN SYS_DICT b on b.id = a.id)
INNER JOIN SYS_DICT c on c.id = a.id
虽然在XML里不加()也可以,不过最好按照上面的形式
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
a.user_id,
b.dictionary_content user_grade,
c.dictionary_content user_subject,
a.user_password,
a.user_name,
a.user_phone,
a.user_address,
a.user_register_time,
d.dictionary_content user_sex,
a.user_sign,
a.user_icon
FROM
teacher_user AS a
INNER JOIN system_dictionary AS b ON b.dictionary_id = a.user_grade
INNER JOIN system_dictionary AS c ON c.dictionary_id = a.user_subject
INNER JOIN system_dictionary AS d ON d.dictionary_id = a.user_sex
WHERE
a.is_deleted = "N" AND a.user_id = #{userId,jdbcType=VARCHAR}
47534bd1bf5a41f7a16c306188af0864
</select>