View Query of Related Tables Mysql

0

I found some answers on the subject, but I still have some doubts, I will try to be as clear as possible. My Bank Example. I have the following Tables

Table

  • Client > id | name | request

  • client_system > customer_id | system_name (foreign)

  • System > id | id_sist | version

  • Service > id_sist | id_num | id_serie (Foreign key)

  • Number > id | type | lic

  • Series > id | nserie |

In the above model I have the CUSTOMER with the primary key ID name and request (data) as follows the other tables, with the exception of the system_user and Service, related as foreign.

What I am tantando is the following, in the customer registry he will have more than one service option, and the service will have a type and type, I have a serial number, when carrying out the query bring all the service and series of the client within the table.

I have to use INNER JOIN for this rule.

I have the Bank model in MySQL Workbench

Thanks to anyone who can clarify my idea.

    
asked by anonymous 15.02.2017 / 15:46

1 answer

0

The JOINs would look like this:

SELECT * FROM cliente c
JOIN cliente_sistema cs ON cs.id_cliente = c.id
JOIN sistema st ON st.id = cd.id_sistema
JOIN servico sv ON sv.id_sist = st.id
JOIN numero n ON n.id = sv.id_num
JOIN serie sr ON sr.id = sv.id_serie;

Just put in SELECT the fields you need.

    
15.02.2017 / 18:46