Here you can find the source of between(String value, String low, String high)
Parameter | Description |
---|---|
value | a value or a column name |
low | a value or a column name |
high | a value or a column name |
public static String between(String value, String low, String high)
//package com.java2s; //License from project: Open Source License public class Main { /**/* ww w. j a va2s . c om*/ * Creates a BETWEEN SQL fragment for Integer value. * The function takes String to allow cases like (8 BETWEEN cola AND colb) and * (cola BETWEEN 1 AND 8) * * @param value * a value or a column name * @param low * a value or a column name * @param high * a value or a column name * @return */ public static String between(String value, String low, String high) { return value + " BETWEEN " + low + " AND " + high; } /** * Creates a BETWEEN SQL fragment like 18 BETWEEN collow AND colhigh * * @param value * @param colLow * @param colHigh * @return */ public static String between(Object value, String colLow, String colHigh) { if (Number.class.isAssignableFrom(value.getClass())) { return value + " BETWEEN " + colLow + " AND " + colHigh; } return "'" + escapeSQLString(value.toString()) + "' BETWEEN " + colLow + " AND " + colHigh; } /** * Very simple escape function for SQL string. * All single quotes will be doubled * * @param command * @return */ public static String escapeSQLString(String command) { return command.replaceAll("'", "''"); } }