pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Doubt with Joins
Date: Mon, 2 Oct 2006 12:41:52 -0300
Message-ID: <55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com> (raw)

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/

Message-ID: <55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com>
Permalink:  ../55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com/
Also on:    postgresql.org/message-id/55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ezequias.rocha@gmail.com
  Subject: Re: Doubt with Joins
  In-Reply-To: <55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox