不包括';不适合mySQL中的掩码位操作
我需要帮助解决一个问题。我有一个位掩码值为10010001的用户。不包括';不适合mySQL中的掩码位操作,mysql,bitwise-operators,Mysql,Bitwise Operators,我需要帮助解决一个问题。我有一个位掩码值为10010001的用户。 列名为值_1。在本栏中,我将与以下值进行比较: |--|----------| |id| value_1| |--|----------| | 1| 00000001 | | 2| 10010001 | | 3| 00000010 | | 4| 10000001 | | 5| 10011001 | |--|----------| 我的问题是: select value_1 from testdb where b
列名为值_1。在本栏中,我将与以下值进行比较:
|--|----------|
|id| value_1|
|--|----------|
| 1| 00000001 |
| 2| 10010001 |
| 3| 00000010 |
| 4| 10000001 |
| 5| 10011001 |
|--|----------|
我的问题是:
select value_1 from testdb
where b'10010001' & value_1;
我的结果是ID 1,2,4,5这看起来很好-但我如何排除id 5,因为最低的第4位(从右侧开始计数)不在源中?假设您的值\u 1数据类型为字符串 试着使用合适的铸件
select value_1 from testdb
where cast( '10010001' as unsigned ) & cast( value_1 as unsigned ) ;
确保值_1的值和掩码的组合位不会导致数字超过掩码作为数字的值
where (b'10010001' & value_1) and (cast((b'10010001' | value_1) as unsigned) <= cast(b'10010001' as unsigned))
<代码>何处(b’10010001’和ValueSe1)和(CB((b’10010001)值ValeE1)为未签名的)值Value1数据类型??4位被设置在<代码> B’10010001/代码>…@ YusufFidan考虑改进标题。一些更明确的东西,比如“排除不符合掩码的值- MySQL中的按位操作”。@liviriniu好吧-这是我的第一个问题-我改变了title@scaisEdge位(8)