D
D
Danil2015-06-24 18:06:50
MySQL
Danil, 2015-06-24 18:06:50

How to merge multiple tables into one?

There are several tables of the form:
id -name, id - suname, id -job
How can I merge them into one table of the form:
id - name - suname - job

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Kuznetsov, 2015-06-24
@NewProject1

If the id is the same (That is, we have one "person" with an id, for example, 5 whose first name is recorded under id 5 in table t1, whose last name is under id 5 in table t2, and whose work is under id 5 in table t3) then:

SELECT 
t1.id, t1.name, t2.suname, t3.job 
FROM t1
INNER JOIN t2 ON t1.id = t2.id
INNER JOIN t3 ON t1.id = t3.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question