mybatis一对多两种mapper写法
第一种
column="id">
sql语句用联表查询
u.*,p.id
as
pid,p.user_id,p.name,p.icon,p.vsersion,p.tags,p.description,p.create_time
as bcreate_time,p.update_time as bupdate_time,p.del_flag from t_user u
LEFT
JOIN t_plugin p ON u.id=p.user_id and u.del_flag=0 and
p.del_flag=0 WHERE
u.user_name LIKE CONCAT('%',#{name},'%') OR
u.nick_name LIKE
CONCAT('%',#{name},'%')
第二种
select="pluginByUid" /> //column='id' 为关联查询所需条件
sql语句使用两个sql语句返回结果
SELECT
* FROM t_user WHERE del_flag = 0 AND ( user_name LIKE CONCAT( '%', #{name},'%')
OR nick_name LIKE CONCAT( '%', #{name},'%'))
//下个sql语句依赖上个
SELECT id,user_id as
userId,name,ic