
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display BIT(1) Fields in MySQL
Let us first create a table. Here, our columns is of type bit(1) −
mysql> create table DemoTable ( isCaptured bit(1) ); Query OK, 0 rows affected (1.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.29 sec)
Following is the query to display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+ | isCaptured | +------------+ | | | | | | | | +------------+ 4 rows in set (0.00 sec)
Here is the query to see bit(1) fields in MySQL to display the fields −
mysql> select isCaptured+0 AS Visible from DemoTable;
This will produce the following output −
+---------+ | Visible | +---------+ | 0 | | 1 | | 0 | | 1 | +---------+ 4 rows in set (0.05 sec)
Advertisements