L
L
LebedevStr2016-04-03 18:52:24
MySQL
LebedevStr, 2016-04-03 18:52:24

How to write a SQL JOINS query?

There is a shop_products table.
id | category_id
--------------------
1 | 79
2 | 59
3 | 784
| 54
5 | 99
There is a shop_category_i18n table.
id | name
--------------------
79 | Toys
59 | TVs
78 | Keyboards
54 | Furniture
99 | Antiques
You need to get the following result:
id | name
--------------------
1 | Toys
2 | TVs
3 | Keyboards
4 | Furniture
5 | Antiques
category_id = id (in table shop_category_i18n).
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nozzy, 2016-04-03
@LebedevStr

select 
t1.id,
t2.name
from 
shop_products as t1
inner join shop_category_i18n as t2 on t2.id = t1.category_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question