Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 3544C2E028E for ; Mon, 26 Nov 2007 16:39:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 24869-05 for ; Mon, 26 Nov 2007 16:39:28 -0400 (AST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by postgresql.org (Postfix) with ESMTP id 8095D2E0291 for ; Mon, 26 Nov 2007 16:39:30 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id h2so1314423ugf for ; Mon, 26 Nov 2007 12:39:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=EilUNjjbqEqCmH/oTRTahwCMDBCMZI1lPKjKOzO07bc=; b=QKPyjQWs4z75Ld8o8EmlrgbU6mI5eIxnig5mclvYwgL+1pj/WmMjGb4XO1yDAl3LEljC08eEabfEBmFcaEMSRg0QJHpuv9W43CTobAjutTWJ2pYCNVxItSIaXq91WujHI3l6HQZDbTiMa4vO44TJGhMzzCDbaxvV7h4+iu2nAMA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=bb9eYbe7Mk7jByn7hwTUoI0VGag+iHWMNwMyst+5EFkrl3apofNE6ygTyMQuuC3aMQuMnGREVKtOBfxUx8Df7tLNsr8BXoGkq8Wn8EdH5LyMTKRqJF3u/XVdHzbgU24hF5B9oAmqPzJoTzFY55pdAQ+NkwgW36JyF1KgBKjqSG4= Received: by 10.67.20.11 with SMTP id x11mr968227ugi.1196109568287; Mon, 26 Nov 2007 12:39:28 -0800 (PST) Received: from ?192.168.1.33? ( [82.12.248.102]) by mx.google.com with ESMTPS id s8sm1619796uge.2007.11.26.12.39.25 (version=SSLv3 cipher=RC4-MD5); Mon, 26 Nov 2007 12:39:26 -0800 (PST) Message-ID: <474B2EFA.6010506@enterprisedb.com> Date: Mon, 26 Nov 2007 20:39:22 +0000 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.14pre (X11/20071020) MIME-Version: 1.0 To: Jonathan Mast CC: pgsql-jdbc@postgresql.org Subject: Re: Queries with 'AND' clauses not returning results References: <85e352e10711261224h71092c7cvfe17df9653874dff@mail.gmail.com> In-Reply-To: <85e352e10711261224h71092c7cvfe17df9653874dff@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/80 X-Sequence-Number: 17835 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