# Mysql-ruby returns wrong record count

**URL:** <https://www.ruby-forum.com/t/mysql-ruby-returns-wrong-record-count/118587>\
**Category:** Ruby\
**Created:** [October 29, 2007, 8:55am UTC](https://www.ruby-forum.com/t/mysql-ruby-returns-wrong-record-count/118587 "2007-10-29T08:55:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 29, 2007, 8:55am UTC](https://www.ruby-forum.com/t/mysql-ruby-returns-wrong-record-count/118587/1 "2007-10-29T08:55:24Z")

</div>

Just started using mysql-ruby, and doing a simply query like this:

select distinct rcrdNo from someTable

I’m getting results back from mysql-ruby that is simply not correct.

rcrdNo is a unique random string that’s 20 characters long. The only  
thing I can think of is somehow going through mysql-ruby that the full  
20 chars is not being considered in DISTINCT?

I can copy/paste the query among different clients, and they all agree  
on the records count except for mysql-ruby. In years of using MySQL,  
I’ve never come across a discrepency in a query like this through a  
client / interface.

Any ideas?

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 29, 2007, 9:04am UTC](https://www.ruby-forum.com/t/mysql-ruby-returns-wrong-record-count/118587/2 "2007-10-29T09:04:23Z")

</div>

Greg W. wrote:

> Just started using mysql-ruby, and doing a simply query like this:  
> select distinct rcrdNo from someTable  
> I’m getting results back from mysql-ruby that is simply not correct.
> 
> rcrdNo is a unique random string that’s 20 characters long. The only  
> thing I can think of is somehow going through mysql-ruby that the full  
> 20 chars is not being considered in DISTINCT?

Duh, all I had to do was output the results of each row, and indeed, the  
values of rcrdNo are only 13 characters long instead of 20.

What’s up with that?

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 29, 2007, 9:09am UTC](https://www.ruby-forum.com/t/mysql-ruby-returns-wrong-record-count/118587/3 "2007-10-29T09:09:20Z")

</div>

Greg W. wrote:

> Greg W. wrote:
> 
> > Just started using mysql-ruby, and doing a simply query like this:  
> > select distinct rcrdNo from someTable  
> > I’m getting results back from mysql-ruby that is simply not correct.
> > 
> > rcrdNo is a unique random string that’s 20 characters long. The only  
> > thing I can think of is somehow going through mysql-ruby that the full  
> > 20 chars is not being considered in DISTINCT?
> 
> Duh, all I had to do was output the results of each row, and indeed, the  
> values of rcrdNo are only 13 characters long instead of 20.
> 
> What’s up with that?

Egads, nevermind. Something funky going on w/data xfr into the test db  
I’m using the script on.

Sorry for the noise 😛

– gw
