Syntax of LIKE in PreparedStatement

From: "Mihai Gheorghiu" <tanethq(at)earthlink(dot)net>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Syntax of LIKE in PreparedStatement
Date: 2002-04-05 21:49:24
Message-ID: 000f01c1dceb$c1ac3bc0$6e646464@New6.Travel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

When I need to translate a PostgreSQL query such as:
SELECT * FROM tbl WHERE name = 'Smith';
into a PreparedStatement, I use something such as:
sql = con.prepareStatement("SELECT * FROM tbl WHERE name = ?");
sql.setString(1, myVariable);

How do I translate
SELECT * FROM tbl WHERE name LIKE '%Smith%';
I'm not sure what happens to ' and %.

Thank you all.

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message tony 2002-04-06 08:46:24 single quotes again
Previous Message Dave Cramer 2002-04-05 21:47:12 Re: Syntax of LIKE in PreparedStatement