\d posts
Table "public.posts"
Column | Type | Modifiers
-------------+------------------------+----------------------------------------------------
id | integer | not null default nextval('posts_id_seq'::regclass)
title | character varying(100) | not null
content | character varying(500) | not null
created_at | date |
updated_at | date |
tags | character varying(55) | not null default '50'::character varying
category_id | integer | not null default 1
Indexes:
"posts_pkey" PRIMARY KEY, btree (id)
\d categories
Table "public.categories"
Column | Type | Modifiers
---------------+-----------------------+---------------------------------------------------------
id | integer | not null default nextval('categories_id_seq'::regclass)
category_name | character varying(50) | not null
created_at | date |
updated_at | date |
Indexes:
"categories_pkey" PRIMARY KEY, btree (id)
Need to count and get how many posts are there for one category. How can i do this?
1 Answer