Join in the database

2

I'm developing software where the user selects the items in his house, selects how long he does not clean them, and at the end he fills out a form to receive an e-mail discount and clean the items. All this data goes to the bank.

However,whendoingtheinnerjointodisplayinthefrontend,theregistereditemonlyrecognizesthefirstID(inthiscase,id1)

How can I resolve this? my tbl_item is:

Mysqlcodeis:

SELECTemail_cadastrado,nome_cadastrado,nome_item,descricaoFROMtbl_cadastradoscJOINtbl_itemiONc.item_cadastrado=i.id_itemJOINstatus_cadastradocadONc.status_cadastrado=cad.idwherecad.id=0"
    
asked by anonymous 26.10.2017 / 18:28

1 answer

3

Your relationship is wrong, the fields in your table "item_educed" should not be so, it must be a N to N relationship with the table of items, having an intermediate table between them, which would have the two values id_catch and id item, so your join would pass through them.

You need to restructure your bank by putting this relational table

Relationship N for N

N: N - The N: N (many-to-many) relationship has a characteristic different from the others. In this case, the data is directly related to the fact, not the entities, as we observed in the other types of relationships seen previously.

It is important to emphasize that there may be no association of facts in situations in which relationships are conditional. In this case, cardinality must be determined through a broad analysis of the possibility of relationships occurring.

Relationship Rules N: N - To establish this type of relationship, we must have three tables, and the third is responsible for relating the other two. For this, it is necessary that these first two tables contain a column that is primary key.

The columns that are primary keys in the first and second tables must be foreign key columns in the third. Thus, this table will have two foreign keys, which form a composite primary key.

    
26.10.2017 / 18:37