Reputation: 1008
I'm sorry for my title, but it's totally right. I don't know PostgreSQL well, but I have to take over other person's application. I know SQL, so it's usually no problem to take over any application based on MSSQL, Oracle, MySQL, PostgreSQL, ... but here is some kind of PostgreSQL facet. Could anyone, please, explain this query to me?
select company_generate_course_template_fc
((select company_id from company order by 1 desc limit 1)::int)
Upvotes: 0
Views: 51
Reputation:
The query calls the function company_generate_course_template_fc()
passing the result of the query: select company_id from company order by 1 desc limit 1
as an argument. The result is cast to an integer using ::int
(see the manual for details)
Apart from the ::int
part (and the different ways of limiting the result to a single row), this wouldn't be much different in other databases
The ANSI SQL equivalent of ::int
would be cast(... as integer)
Upvotes: 2
Reputation: 395
If you are talking about ::int it's type casting from string (company_id) to integer value
Upvotes: 0