Go postgresql LIKE query

前端 未结 3 682
陌清茗
陌清茗 2020-12-14 19:16

I\'m working with Go and PostgreSQL (pq driver), I have the following query

SELECT p.id, p.name, p.description, p.price, p.image, p.rate
FROM products AS p
W         


        
3条回答
  •  一生所求
    2020-12-14 19:48

    You need to put the like pattern in single quotes:

    SELECT p.id, p.name, p.description, p.price, p.image, p.rate
    FROM products AS p
    WHERE LOWER(p.name) LIKE '%' || $1 || '%'
    ORDER BY p.rate DESC;
    

提交回复
热议问题