W
W
w_b_x2017-08-28 20:34:54
MySQL
w_b_x, 2017-08-28 20:34:54

How to get information by ID from another table in one query?

Hello!
I can't figure out how to make a request.
Conventionally, there are two tables:
`products`, with columns: `id`, `title` (product name), `buyer_id` (customer ID, from the `buyers` table)
`buyers`, with columns: `id`, ` name` (customer's name)
The task is simple:
Get in one query as a result a table that has the following columns: `Product ID`, `Product name`, `Customer name`
What will it look like?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Chronic 86, 2017-08-29
@w_b_x

Select p.id, p.title,b.name
From products p
Join buyers b ON p.buyer_id = b.id

S
Stanislav B, 2017-08-28
@S_Borchev

JOIN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question