Hi list,
I have the following query:
select distinct cli.id as id, cli.nome as Nome, c.numero as cardpass, cli.documento as Documento, cli.endereco as Endereco,
cli.complemento as Complemento,
cli.bairro as Bairro, cli.cidade as Cidade, cli.estado as UF,
cli.cep as CEP, cli.telefone as Telefone, cli.email, cli.sexo as Sexo, cli.estado_civil, cli.data_nascimento, cli.escolaridade, c.pontos, cli.informacoes_cliente
from base.cliente as cli, base.cartao as c, base.sessao as s, base.evento as e, base.ingresso as i
where c.cliente_id = cli.id
and c.id = i.cartao_id <-- records only appears when I have records on table "i"
and s.id = i.sessao_id <-- records only appears when I have records on table "i"
and s.evento_id = e.id <-- records only appears when I have records on table "e"
and cli.Nome Like 'ANA%'
and e.nome = 'EVENT1' <-- Some times I don't want to pass this parameter
and s.descricao = 'SESSION 1' <-- Some times I don't want to pass this parameter
and c.estado = 1
order by 1
but my query vary according my parameters. My question is why I only get records that exist in both tables with this "ids" ? (event e and session s)
It is a case of an outer join ? What should I do if I only have a
cli.Nome parameter passed ?
I don't know I I made myself clear.
Regards
Ezequias
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Atenciosamente (Sincerely)
Ezequias Rodrigues da Rocha
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
A pior das democracias ainda é melhor do que a melhor das ditaduras
The worst of democracies is still better than the better of dictatorships
http://ezequiasrocha.blogspot.com/