1 | initial version |
In Postgres SQL, variables are assigned using the "SET" command. The general syntax for assigning variables is as follows:
SET variable_name = value;
For example, to assign a variable named "num" and set its value to 10, the command would be:
SET num = 10;
Note that variables in Postgres SQL are prefixed with a dollar sign ($), so the variable name in the command above would actually be "$num". Once the variable has been assigned, it can be used in subsequent SQL statements by enclosing it in dollar signs, like so:
SELECT * FROM mytable WHERE column = $num;
This would return all rows from the table "mytable" where the value in the "column" column matches the value of the "num" variable.