Answer the question
In order to leave comments, you need to log in
How to write a MySQL query?
There are 2 tables
table1
id | data
...
-----------------------
table2
id | data | table1_id
...
id | data
1 | bla-bla-bla
2 | bla-bla-bla
NULL
table1
id | data
1 | bla-bla-bla
2 | bla-bla-bla
3 | bla-bla-bla
...
--------------------
table2
id | data | table1_id
1 | ... | 2
2 | ... | 3
...
--------------------
id | data | new_stolbik
1 | bla-bla-bla | NULL
2 | bla-bla-bla | 1
3 | bla-bla-bla | 2
Answer the question
In order to leave comments, you need to log in
SELECT
table1.*,
table2.table1_id as new_stolbik
FROM table1
LEFT JOIN table2 ON table2.table1_id = table1.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question