1

plese anyone tell me what the meaning of "t" after this postgres Sql query.

const query = select jsonb_agg(single_day) as availability from (select jsonb_build_object('day', day, 'hours_format', min(hours_format),'time_array', jsonb_agg(jsonb_build_object('start_time', start_time, 'end_time', end_time) order by start_time ASC)) as single_day from provider_availability where user_id = ${user_id} group by day) t,

2
  • 4
    It's a table alias. I.e. a name for the subquery. Commented Apr 5, 2022 at 10:19
  • 4
    It's a table alias Commented Apr 5, 2022 at 10:21

1 Answer 1

2

t is a table alias for the subquery in the FROM clause, which allows you to then reference that table alias in other clauses (e.g WHERE t.start_time = [time]). Just using the alias name on its own immediately after the closing bracket of the subquery is shorthand for writing AS t.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.