A
A
astrotrain2015-09-23 10:13:53
MySQL
astrotrain, 2015-09-23 10:13:53

How to add id field from another table?

I have two tables. In one id of the "project", in the other id of the elements of the project. It is necessary that each element of the project be associated with the project, respectively. Only I don't know how to connect these two databases so that the id field from one table is represented by project_id in another. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sbh, 2015-09-23
@sbh

Могу посоветовать почитать на тему типы связей в БД, 1 к 1, 1 ко многим, многие ко многим. Связать вы хотите скорее всего не базы а таблицы.

G
Gregory, 2015-09-23
@grigruss

SELECT `tableone`.`id`, `tabletwo`.`id` as `idtwo` FROM `tableone` AND `tabletwo` WHERE `tabletwo`.`name`=`tableone`.`name`;

здесь развернутый пример запроса из двух таблиц с условием. выше крыши хватит...
Выхлоп: `id`,`idtwo`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question