Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Wie vergleiche ich (UND) zwei Zeichenfolgen, die eine binäre Maske in mysql darstellen?

Sie können conv verwenden , zB.

select conv('1100', 2, 10) & conv('0110', 2, 10);

Re Kommentar, es scheint für mich zu funktionieren:

mysql> select conv('1001', 2, 10) & conv('0110', 2, 10) = 0;
+-----------------------------------------------+
| conv('1001', 2, 10) & conv('0110', 2, 10) = 0 |
+-----------------------------------------------+
|                                             1 |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select conv('1001', 2, 10) & conv('0111', 2, 10) = 0;
+-----------------------------------------------+
| conv('1001', 2, 10) & conv('0111', 2, 10) = 0 |
+-----------------------------------------------+
|                                             0 |
+-----------------------------------------------+
1 row in set (0.00 sec)