I am trying to do something like this:
select char_length(select text_field from table where key = 1)
This won’t work, and I presume, because the return type of a query is a table, not a string or text variable.
Is there a way to specify row,col of the result from a select statement?
edit: I overlooked to mention, that char_length is a function.
When passing the result of a query to a function, simply wrap the query in brackets:
The outer set of brackets is for the function, the inner set converts a query to a result.
This syntax is not specific to postgres – it applies to all SQL servers.
This link shows the above code executing correctly (thanks to @Fahim Parkar for this)
Although, you could re-factor your query to not require this syntax, nevertheless this is how you “pass the result of a query to a function”.