Query that was working on MySQL is not working on PostgreSQL
My educated guess (while proper information is missing): You declared bin_number as character(n), char(n) or just char data type.

character(n) is an outdated, inefficient, weird data type, but defined in the SQL standard. char (without double quotes!) or char(1) are aliases for character(1).

Typically you do not want to use it. It's a blank-padded data type where all strings containing only blanks or nothing (i.e. the empty string '') are considered identical. Effectively all of these are treated as empty strings because trailing blanks are considered insignificant.

SELECT '  '       &lt;&gt; '';  -- TRUE
SELECT '  '::text &lt;&gt; '';  -- TRUE (identical, because text is default
SELECT '  '::char &lt;&gt; '';  -- FALSE (!!)


Use varchar or text instead.

SQL Fiddle with a matrix of comparisons.

More:


Compare varchar with char
Any downsides of using data type “text” for storing strings?
Would index lookup be noticeably faster with char vs varchar when all values are 36 chars


It's either that, or you have NULL values in the column where you had empty strings in MySQL. Either way, the table definition (\d tbl in psql) in the question and some sample values would allow answers instead of speculation.