
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to display the 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)
- Related Articles
- Using GROUP_CONCAT() on bit fields returns garbage in MySQL? How to fix?
- Bit Fields in C
- How can we display MySQL bit values in printable form?
- Display all fields of a table in MySQL?
- MySQL query to display all the fields that contain a capital letter?
- How to concatenate fields in MySQL?
- How to mask data fields in MySQL?
- What is the best way to display in Terminal a MySQL SELECT returning too many fields?
- How to ORDER BY grouped fields in MySQL?
- Java Program to display Bit manipulation in Integer
- Display 1 for NULL values in MySQL
- 1-bit and 2-bit Characters in Python
- MongoDB query to display all the fields value, except _id
- How to find the minimum values of two or more fields in MySQL?
- Display TRUE FALSE records as 0 1 in MySQL

Advertisements