Posts

Showing posts from 2012

2023-09-13, Wednesday, Cloudy

新工上遇上了挫折。寫好的東西達不到標準需要別人執手尾了。雖然同事說沒關係,但反應了自己的不足。有時反省自己為何做事總是不好,為何別人有留意或想到的事情自己總是忽略。現在覺得是自己天生的思考模式問題,可能看多少書都沒用。或者自己應該更適合做地盤呢類工作,而唔係IT。

Using Like statement in MyBatis 如何在MyBatis使用Like 條件

Using Like statement in MyBatis 如何在MyBatis使用Like 條件 Using like statement in MyBatis does not make the parameter appended with %. The easiest way to make it work, is to use concatenate operator directly in the statement, e.g. + in SQL Server, or || in Oracle. 當要在MyBatis 內使用SQL的Like條件時, %符是不會自動加到參數中的.除了在程式中加入%再傳入參數, 其中一個方法是在SQL 的定義中把%用連接符連在一起, 如SQL SERVER 的+ 或ORACLE 的||. SQL Server: <select id="sampleSelectStatment" resultmap="BaseResultMap">   select a,b,c from tablea where a like '%'+#{param}+'%' </select> SQL Server: <select id="sampleSelectStatment" resultmap="BaseResultMap">   select a,b,c from tablea where a like '%'||#{param}||'%' </select>