Concat inside a WHERE clause in postgres

I have a question about the concat function in PostgreSQL.

This sentence works well in MySQL:

SELECT * FROM words WHERE CONCAT (word,' ',gender,' ',semantic) LIKE '%"+value+"%'. 

Value is a variable that changes in my Java program.

But I need to work the same in postgresql. How can I kann concatenate inside a WHERE clause using postgres, given the variable "value" that will change its value?

+4
source share
2 answers

In Postgresql, you combine using the following syntax:

 (users.first_name || ' ' || users.last_name) 

Link : http://www.postgresql.org/docs/9.1/static/functions-string.html

+12
source

You can also use this for postgresql:

 concat_ws(' ', campo1, campo2) like '%value%' 

Note that there is a space between single quotes

+1
source

Source: https://habr.com/ru/post/1490789/


All Articles