pg.ddx.io pgsql-jdbc@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Queries with 'AND' clauses not returning results 2+ messages / 2 participants [nested] [flat]
* Queries with 'AND' clauses not returning results @ 2007-11-26 20:24 Jonathan Mast <jonathan.h.mast@gmail.com> 0 siblings, 1 reply; 2+ messages in thread From: Jonathan Mast @ 2007-11-26 20:24 UTC (permalink / raw) To: pgsql-jdbc I have some jsp with calls to our pg database, and yes, I know this is not the optimal way to do it, but we can't stop everything to re-engineer our website to use Struts or whatever. That said, the problem is that statements such as: "SELECT * FROM tbl_someTable WHERE email='nobody@nowhere.com' ; work fine while statements like this don't work (no records returned): "SELECT * FROM tbl_someTable WHERE email='nobody@nowhere.com' AND password='abcd'"; And quoting the field 'password' doesn't make a difference. I know such records actually exist because I'm printing out the query on the webpage, copying it to pgAdmin and executing with results. I have no idea why its not working. specs: Apache 1.3.33 Tomcat 5.5.17 postgresql 8.1.3 ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Queries with 'AND' clauses not returning results @ 2007-11-26 20:39 Heikki Linnakangas <heikki@enterprisedb.com> parent: Jonathan Mast <jonathan.h.mast@gmail.com> 0 siblings, 0 replies; 2+ messages in thread From: Heikki Linnakangas @ 2007-11-26 20:39 UTC (permalink / raw) To: Jonathan Mast <jonathan.h.mast@gmail.com>; +Cc: pgsql-jdbc Jonathan Mast wrote: > I have some jsp with calls to our pg database, and yes, I know this is > not the optimal way to do it, but we can't stop everything to > re-engineer our website to use Struts or whatever. Don't worry, we're not here to judge your development methodologies :). > specs: > Apache 1.3.33 > Tomcat 5.5.17 > postgresql 8.1.3 Running an old version of PostgreSQL, however, is frowned upon ;-). Seriously, you should upgrade. > That said, the problem is that statements such as: > "SELECT * FROM tbl_someTable WHERE email='nobody@nowhere.com' ; > work fine > > while statements like this don't work (no records returned): > "SELECT * FROM tbl_someTable WHERE email='nobody@nowhere.com' AND > password='abcd'"; > And quoting the field 'password' doesn't make a difference. > > I know such records actually exist because I'm printing out the query > on the webpage, copying it to pgAdmin and executing with results. That obviously should work, so there's something else than just that query involved here. Perhaps a quoting problem or something, but it's hard to say without seeing the actual code. BTW, if the values for email and password are coming from user input, you must be careful to quote them properly, or use a prepared statement. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-11-26 20:39 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2007-11-26 20:24 Queries with 'AND' clauses not returning results Jonathan Mast <jonathan.h.mast@gmail.com> 2007-11-26 20:39 ` Heikki Linnakangas <heikki@enterprisedb.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox