当将BIN()
字符串函数与WHERE子句一起使用时,其返回的输出将取决于WHERE子句中给出的条件。在这种情况下,我们必须在WHERE子句中使用二进制值。例如,假设我们有一个名为“ Student”的表,并且我们只想获取“ id”列的二进制值大于1010的那些行,那么我们可以编写以下查询-
mysql> Select *,Bin(id) from student where BIN(id) > 1010 ; +------+---------+---------+-----------+---------+ | Id | Name | Address | Subject | Bin(id) | +------+---------+---------+-----------+---------+ | 15 | Harshit | Delhi | Commerce | 1111 | | 20 | Gaurav | Jaipur | Computers | 10100 | +------+---------+---------+-----------+---------+ 2 rows in set (0.00 sec)