Question from the SQL - Fundamentals test

Write a SQL query to retrieve the names of products and their categories.

Easy

Given the following 'products' and 'categories' tables:

products:
| product_id | name        | category_id |
|------------|-------------|-------------|
| 1          | Product A   | 1           |
| 2          | Product B   | 2           |
| 3          | Product C   | 1           |

categories:
| category_id | name      |
|-------------|-----------|
| 1           | Category 1|
| 2           | Category 2|

Which SQL query retrieves the names of products and their categories?

Author: GhadaStatus: Published(Update)Question passed 479 times
Edit
0
Community Evaluations
developer avatar
Grégory
11/07/2024
la plus pertinente c'est trÚs subjectif. Le `LEFT JOIN` permettra d'obtenir les produits sans catégories ce qui peut etre plus pertinent ... selon le contexte