在123xxx数字中找到的WHERE子句

时间:2015-08-09 15:19:19

标签: sql firebird firebird2.5

我尝试搜索包含

的所有行
123000 - 123xxx

所以最后三个是未知但必须填写。

所以我不想找到例如

12300 or 1230000

4 个答案:

答案 0 :(得分:3)

select * from your_table
where some_column between 123000 and 123999

答案 1 :(得分:1)

如果值是数字,那么只需使用:

where value >= 123000 and value < 124000

如果value是字符串:

where char_length(value) = 6 and left(value, 3) = '123'

答案 2 :(得分:1)

对于Firebird 2.1及以上版本

select * from table_name
where  
  (BIN_AND(table_name.field_name,123000) = 123000)
带参数

的存储过程中的

select * from table_name
where  
  (BIN_AND(table_name.field_name,:p) = :p)

答案 3 :(得分:0)

如果您确定该字段始终为int,则可以使用

taskBoard.storeUser = item.id;

//-------- taskBoard object
        success: function (json) {
            $.each($(json), function (index, item) {
                taskBoard.storeUser = item.id;
                doOtherFunction();
            });
//--------

function doOtherFunction()
{
    //the callback function fired from the success.
    alert(taskBoard.storeUser); //this will alert with the value set.
}

Doc for _可以在这里找到:here

简而言之,_是一个通配符,所以在一个只能是int的字段上,这应该匹配123000到123999

如果您必须找到123的任何引用,其中最后3个值可以是任何值,包括字符

,这也可能很有用。

此致 杰米