There are several tables with user data. In the first one his main data, in the second one his phones, in the third one his mails, in the fourth contact details and in the fifth data on the work. In the main view, under each contact there is a button, in the attribute of which (data-value) is written id <a href="#" id="edit-contact-modal" data-value="<?=$contact['contid']?>" class="btn btn-purple entity-btn-params waves-effect waves-light btn-xs mb-5" data-toggle="modal" data-target="#edit-contact-win">Редактировать</a> . In each of the tables there is a contid field, which is common to all. It is necessary to display the interconnected data in one common modal window, taking into account that there may be several phones and emails, which means that the fields should be automatically generated, but so far I don’t know how to do this.

  • one
    For each table containing multi-attributes, perform GROUP BY by user and GROUP_CONCAT by multi-attribute. To link such subqueries and other tables with attributes ( INNER or LEFT JOIN ) with the main table and output all the data in the required format with the necessary field names. - Akina

1 answer 1

Use the JOIN command, namely INNER JOIN for you. In a single query, you can combine as many tables as you like.

  • There are two phones in one table. In the other two soaps. The result - 4 entries ... so the author clearly does not need it. As well as not to miss a retrograde, in principle, not using e-mail. - Akina