</mapper>select b.*,u.userId u_userId,u.username u_username,u.password u_password from blog b left join user u on u.userId=b.userId<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</mapper>select b.*,u.username u_username,u.userId u_userId,u.password u_password from blog b left join user u on b.userId=u.userId where u.userId=#{userId}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
like 使用 #{} 会报错
例如一段sql代码
select * from user where username like '%#{username}%';
当username=admin 相当于
select * from user where username like '%'admin'%'
这里也不能直接使用 ${}.
可以使用mysql内置函数 concat() 来处理
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"