MySQL使用like出現 操作MySQL數據庫報出:Parameter index out of range (1 > number of parameters


...
sql = "...where 1=1  and s.content like '%?%'";
sqlValue.add(content);
...
一直出現錯誤Parameter index out of range (1 > number of parameters, which is 0)
自己修改 sql = "...where 1=1  and s.content like '%"+content+"%'";這樣沒有問題,但是感覺有些生硬。
詢問了同事說用concat比較好
sql = "...where 1=1  and s.content like concat('%',?,'%')";
sqlValue.add(content);
...

發佈了298 篇原創文章 · 獲贊 9 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章