I'm not reproducing your issue, which tells me you may have made a mistake when creating your table? I don't think the query is the issue.
Here's my example, step by step. First, we create the table (I'm using PostgreSQL 9.1):
CREATE TABLE example(
id int,
name1 text,
name2 text
);
Then I populate it with these rows:
INSERT INTO example (id, name1, name2)
VALUES (0, 'Bird', 'Cheese');
INSERT INTO example (id, name1, name2)
VALUES (1, 'Bear', 'Honey');
INSERT INTO example (id, name1, name2)
VALUES (2, 'Fish', 'Fish');
INSERT INTO example (id, name1, name2)
VALUES (3, 'Bread', 'Bread');
Okay, so now, when I use a query with your format, I should get the rows with id = 2 and id = 3:
SELECT * FROM example WHERE name1 = name2;
Which returned the correct result:
id | name1 | name2
----+-------+-------
2 | Fish | Fish
3 | Bread | Bread
I suggest you try this example to see if it works with your version of PostgreSQL. If it does, fantastic! That means there is probably just mistake in your table implementation somewhere (perhaps mismatched data types?). If the example does not work, perhaps there is something wrong with your PostgreSQL version
NULL
? Are the types for the two columns the same. – Gordon Linoff Jul 14 '14 at 16:05