Node-postgres: prepared statements and LIKE

Created on 27 Jan 2011  路  2Comments  路  Source: brianc/node-postgres

Currently this gives me an error:
SELECT * FROM table WHERE field LIKE '%$1%'
Saying:
bind message supplies 1 parameters, but prepared statement "" requires 0

How do you go about using prepared statements with LIKE? Not sure if I'm missing something, didn't see it in docs. Thanks again! This library is working out great BTW.

discussion

Most helpful comment

Glad the library's working out well for you.

Line #45

https://github.com/brianc/node-postgres/blob/master/test/integration/client/api-tests.js

client.query('SELECT * FROM band WHERE name LIKE $1 ORDER BY name', ['the %'], assert.calls(function(err, result) {...

Is that what you are looking for?

All 2 comments

Glad the library's working out well for you.

Line #45

https://github.com/brianc/node-postgres/blob/master/test/integration/client/api-tests.js

client.query('SELECT * FROM band WHERE name LIKE $1 ORDER BY name', ['the %'], assert.calls(function(err, result) {...

Is that what you are looking for?

yes, thank you, that worked, knew there was a way :)

Was this page helpful?
0 / 5 - 0 ratings