mgutz / dat

Go Postgres Data Access Toolkit
Other
612 stars 62 forks source link

`LIKE` operator in queries #76

Closed saniales closed 6 years ago

saniales commented 6 years ago

How can I use LIKE operator in queries? Here an example

SELECT * 
FROM users
WHERE email LIKE $1

note that $1 is an escaped parameter for %somevalue%

saniales commented 6 years ago

OK just found the solution which is by using || operator. I write here hoping it is helpful

SELECT *
FROM users
WHERE email LIKE '%' || $1 || '%' --concat operator

now it is possible to pass the parameter as usual