Re: Syntax of LIKE in PreparedStatement - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: Syntax of LIKE in PreparedStatement
Date
Msg-id 1018043232.20073.102.camel@inspiron.cramers
Whole thread Raw
In response to Syntax of LIKE in PreparedStatement  ("Mihai Gheorghiu" <tanethq@earthlink.net>)
List pgsql-jdbc
Mihai

just set the prepared statement to

"select * from table where name like ?"

and then do a setString(1,"%Smith%")

Dave
On Fri, 2002-04-05 at 16:49, Mihai Gheorghiu wrote:
> 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.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>




pgsql-jdbc by date:

Previous
From: "Mihai Gheorghiu"
Date:
Subject: Syntax of LIKE in PreparedStatement
Next
From: tony
Date:
Subject: single quotes again