2
I have a select that looks for data from three different tables, but has some common fields between these three tables. My question is how to get the data of these fields, which has the common name with the other tables.
My select is like this:
SELECT suporte_cad.reg,suporte_cad.data,suporte_cad.status,
suporte_cad.nmcontato, suporte_cad.mensagem ,
serv_cad.nmgrupo,serv_cad.dsservico, suporte_det.reg,
suporte_det.data, suporte_det.nmContato, suporte_det.nmUsuario,
suporte_det.mensagem
FROM suporte_cad,serv_cad,suporte_det where cnpj='$getCnpj'
and suporte_cad.idservcad=serv_cad.idservcad and suporte_det.reg='$reg'
and suporte_cad.reg = '$reg'
I want to get the message field from the tables support_cad and support_det
I don’t understand, you’re taking the fields you want.
– Maniero
SQL AS http://www.w3schools.com/sql/sql_alias.asp
– Pedro Henrique
@bigown I’m guessing the problem is at the other end (PHP?) when reading the results by column name.
– bfavaretto
@bfavaretto killed, I think it’s right, he would use elsewhere, maybe even in the
JOIN
that would be put after.– Maniero
ALIAS solved me, did exactly what I wanted
– Meeeefiu