See table by foreign key in C #

2

So, I have a Pizzaria project and I have some tables, such as: Customer Registration, Employee Registration, Order Master and etc. I've already created a Client and Employees table and that's OK. In the Order Master table there are two fields that ask for the Employee ID and Customer ID. Can you select the Employee and the Customer just by searching the name of both? Follow the link to understand better: link The foreign keys of the Order are: id_function and customer_id.

    
asked by anonymous 04.10.2015 / 23:39

1 answer

1

You could join the Employee table with Customer and Order.

Ex:

 SELECT CLIENTE.NOME, CLIENTE.ID, FUNCIONARIO.NOME, FUNCIONARIO.ID, PEDIDO.ID
 FROM PEDIDO
 INNER JOIN CLIENTE
 ON CLIENTE.ID = PEDIDO.ID_CLIENTE
 INNER JOIN FUNCIONARIO.ID 
 ON  ON FUNCIONARIO.ID = PEDIDO.ID_FUNCIONARIO
 WHERE CLIENTE.NOME = 'LUÃ GOVINDA MENDES SOUZA'

However, I do not advise you to do this because CLIENT.NAME and FUNCIONARIO.NOME are not table keys, having the possibility of receiving more than one record in the above query.

    
08.10.2015 / 13:41