Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id AB3E89FB21E for ; Mon, 2 Oct 2006 12:41:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 95147-01 for ; Mon, 2 Oct 2006 15:41:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170]) by postgresql.org (Postfix) with ESMTP id 81EA19FB20D for ; Mon, 2 Oct 2006 12:41:53 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id 30so498992ugc for ; Mon, 02 Oct 2006 08:41:52 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=Otefzcjj25M0meZf7qFkkdh7gLUg7NpzXLzYbanaWqkprqKfQoF3uOQlupayq6nZkmz7cG1tflREPgmnar4HupKzsx3vPjAblEGKuHVQbKfnQuiL/6fJUStsre+qnjZwrizphnHjZBIzX9GwQjKVH2G64wtHV4sYw0QYZBuYjlk= Received: by 10.66.224.3 with SMTP id w3mr2759820ugg; Mon, 02 Oct 2006 08:41:52 -0700 (PDT) Received: by 10.67.94.13 with HTTP; Mon, 2 Oct 2006 08:41:52 -0700 (PDT) Message-ID: <55c095e90610020841i134d19afwbf6a33af0ed50c7a@mail.gmail.com> Date: Mon, 2 Oct 2006 12:41:52 -0300 From: "Ezequias Rodrigues da Rocha" To: pgsql-sql@postgresql.org Subject: Doubt with Joins MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_45897_10831710.1159803712219" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.574 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_30_40, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200610/3 X-Sequence-Number: 26392 ------=_Part_45897_10831710.1159803712219 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 a= s e, base.ingresso as i where c.cliente_id =3D cli.id and c.id =3D i.cartao_id <-- records only appears when I have records on table "i" and s.id =3D i.sessao_id <-- records only appears when I have records on ta= ble "i" and s.evento_id =3D e.id <-- records only appears when I have records on ta= ble "e" and cli.Nome Like 'ANA%' and e.nome =3D 'EVENT1' <-- Some times I don't want to pass this parameter and s.descricao =3D 'SESSION 1' <-- Some times I don't want to pass this parameter and c.estado =3D 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 --=20 =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Atenciosamente (Sincerely) Ezequias Rodrigues da Rocha =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- A pior das democracias ainda =E9 melhor do que a melhor das ditaduras The worst of democracies is still better than the better of dictatorships http://ezequiasrocha.blogspot.com/ ------=_Part_45897_10831710.1159803712219 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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,=20 cli.bairro as Bairro, cli.cidade as Cidade, cli.estado as UF,
cli.cep a= s CEP, cli.telefone as Telefone, cli.email, cli.sexo as Sexo, cli.estado_ci= vil, cli.data_nascimento, cli.escolaridade, c.pontos, cli.informacoes_clien= te
from base.cliente as cli, base.cartao as c, base.sessao as s, base.even= to as e, base.ingresso as i
where c.cliente_id =3D cli.id
and c.id =3D i.cartao_id&nbs= p; <-- records only appears when I have records on table "i"
and s.id =3D i.sessao_id <-- records onl= y appears when I have records on table "i"
and s.evento_id =3D= e.id <-- records only appears when I have r= ecords on table "e"
and cli.Nome Like 'ANA%'
a= nd e.nome =3D 'EVENT1'  <-- Some times I don't want to pass this pa= rameter
and s.descricao =3D 'SESSION 1' <-- Some times I don't want t= o pass this parameter
and c.estado =3D 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)

I= t is a case of an outer join ? What should I do if I only have a=20 cli.Nome parameter passed ?

I don't know I I made myself clear.
<= br>Regards
Ezequias
--
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-= =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-=3D-
       =             &nb= sp;            =   Atenciosamente (Sincerely)
            = ;            Ez= equias Rodrigues da Rocha
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-= =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-
A pior das democracias ainda =E9 melhor do que= a melhor das ditaduras
The worst of democracies is still better than th= e better of dictatorships
http://ezequiasrocha.bl= ogspot.com/ ------=_Part_45897_10831710.1159803712219--