MyBatis dynamic “union all”
Take a look at the following union sql fragment. What if includeFoo is false? You will end up with union all (select * from bar) , which is not legal sql. There must be a result set before “union all” The solution is to use <trim/> tag It means: if what’s inside <trim/> starts with …