0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

2WAYSQLでのwhere句の書き方

Posted at

2WAYSQLでのwhere句の書き方。自分用メモ。

/*BEGIN*/
where
/*END*/

まず /*BEGIN*/ と /*END*/ でwhere句をくくる。
(大文字で書くこと。)

/*BEGIN*/
where

  //if文なしの場合の完全一致検索
  user_cd = /*userCd*/'dummy'

  //if文ありの場合の完全一致検索
  /*IF searchItem != null && !"".equals(searchItem)*/
  user_name = /*searchItem*/'%dummy%'
  /*END*/

  //if文ありの場合の部分一致検索
  /*IF searchItem != null && !"".equals(searchItem)*/
  user_deaprtment like '%' || /*searchItem*/'%dummy%' || '%'
  /*END*/

//if文ありの場合の比較検索 その1
  /*IF lastLoginDateFrom != null && !"".equals(lastLoginDateFrom)*/
  and login_date >= /*lastLoginDateFrom*/''
  /*END*/

//if文ありの場合の比較検索 その2
  /*IF lastLoginDateTo != null && !"".equals(lastLoginDateTo)*/
  and login_date <= /*lastLoginDateTo*/''
  /*END*/
/*END*/

if文を書く場合は、
/*IF (条件)*/ と /*END*/ でくくること。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?