Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Which one better prioritize the results start with the searched string ?
- Version 1:
- @Query("Select org from Organisation org " +
- "WHERE org.status in ('ACTIVATED', 'SUSPENDED') " +
- "AND (UPPER(org.orgName) LIKE UPPER('%' || :name || '%') OR org.identificationCode LIKE %:code% ) " +
- "AND (:interest IS NULL OR org.interestRepresented = :interest)" +
- "ORDER BY CASE " +
- "WHEN UPPER(org.orgName) LIKE UPPER(CONCAT(:name, '%')) THEN 1 " +
- "WHEN org.identificationCode LIKE CONCAT(:code, '%') THEN 2 " +
- "ELSE 3 END")
- Version 2:
- @Query("SELECT org from Organisation org " +
- "WHERE org.status in ('ACTIVATED', 'SUSPENDED') " +
- "AND (LOCATE(UPPER(:name), UPPER(org.orgName)) > 0 OR LOCATE(:code, org.identificationCode) > 0) " +
- "AND (:interest IS NULL OR org.interestRepresented = :interest)" +
- "ORDER BY LOCATE(UPPER(:name), UPPER(org.orgName)) + LOCATE(:code, org.identificationCode)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement