如何使用 ORMLite querybuilder 使这个查询开始数字?

How to make this query start digits with ORMLite querybuilder?

我有 2 个问题。

  1. 此查询是否正确获取以数字开头的行?

    select * from [tables] where [column] like '[0-9]%'

  2. 如何到达 ormlitequeryBuilder

我在几次尝试的最后找到了答案。

  1. 以数字开头的查询

    SELECT * FROM [tables] WHERE [column] >= '0' AND [column] <= '9'

    使用正则表达式:

    SELECT * FROM [tables] WHERE [column] REGEXP '[0-9]+'

  2. 如果要在ORMLite中使用正则表达式查询,请使用GenericRawResults。 举例如下。

    GenericRawResults<T> rawResults = getYourDao().queryRaw(
        "SELECT * FROM " + [tables] + " WHERE " + [column] + " REGEXP '[0-9]+'",
        getYourDao().getRawRowMapper(), String...params);
    List<T> dataList = rawResults.getResults();