The student table has an id_family column — this is family status (for example: complete, incomplete)

There is another family table with a column name where the value is written (Full, Incomplete)

There is another status table with a status column where the meanings are written down (Parents are divorced, Single Mother, Without mother, Without father)



I need to connect them to student (family)

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants of rjhdby , Mike , Vadim Ovchinnikov , AK , aleksandr barakin 18 Jan '17 at 21:51 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • a family has several meanings, for example, Complete, but Parents are divorced - As Lan
  • or in Incomplete several meaning for example, without a father, single mother - As Lan
  • one
    Try to write your question more clearly. And it is even difficult to guess what it is about. There is a link to the question "edit", use it, and do not write in the comments - Mike
  • On the vskidku you need from the students to refer to the status table. And family generally throw it away and get by with the yes / no field in the status table - Mike
  • This picture question should be closed, because the answer to it is useless for the knowledge base, because search engines (so far) do not know how to index the meaning expressed by the picture - aleksandr barakin

1 answer 1

Use the LEFT JOIN , run the cycle further and collect the data as you need.

  • Why exactly LEFT? I do not see in the input a single hint that in studetns there may be values ​​that are missing in reference books (family, status). - Mike
  • Well, because you ultimately need to get students with options. The student is the main unit in this case, so you need to build on it. Accordingly, it is necessary to attach data to it. - Rochfort
  • Well, it was said that "or in the Incomplete several values, for example, without a father, single mother", we need to collect them all. then left is needed - Rochfort
  • I do not know where you saw "the field is one, not two for the father and mother" - Rochfort
  • I read the question. There is even more interesting. The first sentence - in the table one field id_family (complete / not complete). And the third sentence is the status table, which has nothing to do with the previous two. At the moment, I generally understand the question so that it is not about how to make a sample, but about how best to present this information in the database, i.e. how to remake the database structure. In general, the author needs at least something to explain what he asks about - Mike