Doubt with Joins

From: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Doubt with Joins
Date: 2006-10-02 15:41:52
Message-ID: 55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.Nomeparameter 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/

Browse pgsql-sql by date

  From Date Subject
Next Message Rodrigo Sakai 2006-10-02 16:39:38 SEQUENCES
Previous Message chester c young 2006-10-02 15:15:03 Re: regexp_replace usage