I have 3 tables in my database, CUSTOMERS, DISTRIBUTORS and EXPORTS and I have a production order table where I get the type of customer (Distributor, customer or export) and the ID of each one. the doubt is: how can I put a if
in select
, so I can join the 3 tables with the order of production? type like this:
if (tipocliente == CLIENTE)
select CamposDaTabela from OrdemDeProduçao inner join Cliente
if (tipocliente == Distribuidor)
select select CamposDaTabela from OrdemDeProduçao inner join Distribuidor
if (tipocliente == exportaçao)
select CamposDaTabela from OrdemDeProduçao inner join Exportaçao
Would you like to do so within the same sql?