# How can we use BIN() function with MySQL WHERE clause?

When BIN() string function is used with WHERE clause, the output returns by it will depend upon the condition given in WHERE clause. In this case, we must have to use binary value in WHERE clause. For example, suppose we have a table named ‘Student’ and we want to get only those rows where the binary value of column ‘id’ is higher than 1010, then we can write following query −

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)