# Treatment of bit(n) type in mysql where n\>1

**URL:** <https://forum.inductiveautomation.com/t/treatment-of-bit-n-type-in-mysql-where-n-1/11584>\
**Category:** Ignition\
**Created:** [April 26, 2016, 10:12pm UTC](https://forum.inductiveautomation.com/t/treatment-of-bit-n-type-in-mysql-where-n-1/11584 "2016-04-26T22:12:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![driverk](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@driverk](https://forum.inductiveautomation.com/u/driverk)\
**Post date:** [April 26, 2016, 10:12pm UTC](https://forum.inductiveautomation.com/t/treatment-of-bit-n-type-in-mysql-where-n-1/11584/1 "2016-04-26T22:12:51Z")

</div>

We have been qualifying MySQL 5.7 and found that the bit type is handled differently in Ignition for bit(n) where n\>1. We went back and checked MySQL 5.6 and found this also to be the case.

Assume a create table statement such as

```auto
create table test (id int(11), b1 bit(1) default b'0', b3 bit(3) default b'111')
```

when I populate this table with a few rows and issue the query

```auto
select * from test
```

I get the following in MySQL Workbench

`1, 0, 7
2, 0, 7
3, 0, 7`

In the Ignition database query browser, I get something like

`1,false,[B@1dcaaa10
2,false,[B@4dc713c3
3,false,[B@709c8237`

I get the same result with the following query.

```auto
select id,b1,cast(b3 as binary) from test
```

If I use the following, the string for the third column is empty.

```auto
select id,b1,cast(b3 as char) from test
```

I tried using the same driver with a Java program, and ResultSet.getString(“b3”) returns “7”.

Ignition 7.8.2  
mysql connector/j 5.1.38  
java 1.8.0\_91

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 26, 2016, 10:37pm UTC](https://forum.inductiveautomation.com/t/treatment-of-bit-n-type-in-mysql-where-n-1/11584/2 "2016-04-26T22:37:27Z")

</div>

The JDBC docs say bit(n) for n\>1 is represented as a byte[]. I’m not sure in what context you’re trying to use this or if that’s helpful or not.
