Wayne Oliver <wayn0.ml@gmail.com> writes:
> [ query works when done by hand, not so much when done by java program ]
I'd bet good money that there's more than one table named "order_details",
some of which have an "mdn" column while others don't. Most likely the
tables are in different schemas and you get the different results
because you and the program are running with different search_path
settings. But I've seen at least one case where the person wasn't even
connecting to the same database as his program was.
You could try something like
\d *.order_details
to check for the same-table-different-schemas theory.
regards, tom lane