I came across this operator :=
in a postgresql function:
searchsql:= searchsql || ' WHERE 1=1 ' ;
I googled but cannot find the answer, what does it mean?
:= is the assignment operator in PL/pgSQL.
PostgreSQL Comparison OperatorsChecks if the values of two operands are equal or not, if yes then condition becomes true. (a = b) is not true. Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. (a !=
SELECT * FROM spatial_ref_sys WHERE srtext LIKE '%\ /%'; Sometimes these ticks are very useful for searching special characters in a database.
Postgresql regexp_replace special charactersSELECT regexp_replace('[email protected]','[^\w]+',''); In the above code, the source is '[email protected]' with the special character @, the pattern is '[^\w]+', which means replacing everything that is not number, digit, underline with the nothing.
:=
is the assignment operator in PL/pgSQL
The expression
searchsql:= searchsql || ' WHERE 1=1 ' ;
appends the string ' WHERE 1=1 '
to the current value of the variable searchsql
See the manual for details:
http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With