Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Bin Function In Sql in SQL

Bin Function In Sql in SQL

? BIN() Function in SQL

The BIN() function converts an integer number to its binary (base-2) string representation.


? Syntax

BIN(number)
  • number: An integer value.

  • Returns a string representing the binary form of the number.


? Examples

1. Convert 5 to binary

SELECT BIN(5);-- Returns '101'

2. Convert 10 to binary

SELECT BIN(10);-- Returns '1010'

3. Convert 0 to binary

SELECT BIN(0);-- Returns '0'

?? Notes

  • Available in MySQL and some other SQL dialects (but not all).

  • Input should be an integer.

  • Returns the binary string without any prefix (0b).


Let me know if you want examples converting binary back to decimal or using bitwise operators in SQL!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql