0
I’m having a problem performing a query.
The original table calls tbl_operacao
, and contains the fields:
id
, tipo_operacao
, idimovel
, idproprietario
, idlocatario
, idseguro
, idvalores
.
When I call the values of idproprietario
and idlocatario
values come equal.
SELECT
`tbl_operacao`.`id`,
`tbl_operacao`.`tipo_operacao`,
`tbl_imovel`.`descricao`,
`tbl_endereco`.`endereco`,
`tbl_endereco`.`num`,
`tbl_endereco`.`bairro`,
`tbl_pessoas`.`nome`,
`tbl_pessoas`.`sobrenome`,
`tbl_pessoas`.`nome` as 'nome2'
FROM
`tbl_operacao`
JOIN `tbl_imovel`
ON (`tbl_operacao`.`idimovel` = `tbl_imovel`.`id`)
JOIN `tbl_endereco`
ON (`tbl_operacao`.`idimovel` = `tbl_imovel`.`id` AND `tbl_imovel`.`idendereco` = `tbl_endereco`.`id`)
JOIN `tbl_pessoas`
ON (`tbl_operacao`.`idproprietario` = `tbl_pessoas`.`id`)
JOIN `tbl_pessoas` as ps2
ON (`tbl_operacao`.`idlocatario` = ps2.`id`)
I’ll need to create a stored Procedure or a Function to get the right values?
Thank you very much, I didn’t know you could put aliases at the source.
– Henrique Madson