Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

:= sql operator in pgsql function [duplicate]

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?

like image 714
dtjmsy Avatar asked Nov 26 '14 14:11

dtjmsy


People also ask

What does := mean in Postgres?

:= is the assignment operator in PL/pgSQL.

Is Equal operator in PostgreSQL?

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 !=

How do I find special characters in PostgreSQL?

SELECT * FROM spatial_ref_sys WHERE srtext LIKE '%\ /%'; Sometimes these ticks are very useful for searching special characters in a database.

How do I remove special characters from a string in PostgreSQL?

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.


1 Answers

:= 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

like image 139
a_horse_with_no_name Avatar answered Oct 13 '22 21:10

a_horse_with_no_name