I have two different tables named artists and artworks. I want to retrieve data from both tables and show them in Summary table.
Condition here is : get name (there are other columns in this table) from artists table and get the number of total artworks from artworks table. Show them in Summary table.
artists |-------------------| | id | name | |-------------------| | 1 | A | |-------------------| | 2 | B | |-------------------| | 3 | C | |-------------------| artworks |-----------------------------------------------------| | id | artist_id | title | medium | |-----------------------------------------------------| | 1 | 1 | ABC | Oil | |-----------------------------------------------------| | 2 | 1 | DEF | Water | |-----------------------------------------------------| | 3 | 1 | GHI | Water | |-----------------------------------------------------| | 1 | 2 | JKL | Oil | |-----------------------------------------------------| | 2 | 2 | MNO | Water | |-----------------------------------------------------| | 3 | 3 | PQR | Oil | |-----------------------------------------------------| This is what I want:
Summary |-------------------------------------------| | No | Artist Name | Total Artwork | |-------------------------------------------| | 1 | A | 3 | |-------------------------------------------| | 2 | B | 2 | |-------------------------------------------| | 3 | C | 1 | |-------------------------------------------| Any help will be highly appreciated. Thanks for your time.