Hi there,
I would like to know what is missing in the select instruction below because
is repeating 3 times each record. I tried to use
DDepen CROSS JOIN HT_DBAU001_DCliente and that was worst because brought me
much more rows repeated!!!
Thanks,
VILMAR
BRAZIL
SELECT distinct DDepen.DPCliente, DDepen.DPNome, DDepen.DPEmail,
DDepen.DPSenha, HT_DBAU001_DCliente.CLSITU
FROM DDepen,HT_DBAU001_DCliente
WHERE (DDepen.DPCliente BETWEEN 1 AND 4) AND (HT_DBAU001_DCliente.CLSITU
BETWEEN 8 AND 10)
ORDER BY DDepen.DPCliente, DDepen.DPNome
Brings me this:
DPCliente DPNome DPEmail
DPSenha CLSITU
-- --- --
-- -- --
--
1 José jr@.XXX.com.br
00000 8.0
1 José jr@.XXX.com.br
00000 9.0
1 José jr@.XXX.com.br
00000 10.0
3 Marinho
lider@.XXX.com.br 00000 8.0
3 Marinho
lider@.XXX.com.br 00000 9.0
3 Marinho
lider@.XXX.com.br 00000 10.0
(6 row(s) affected)Difficult to explain in a short email but do a google on 'cartesian product'
or 'cross join'. Also, review this in BOL:
Using Cross Joins
A cross join that does not have a WHERE clause produces the Cartesian
product of the tables involved in the join. The size of a Cartesian product
result set is the number of rows in the first table multiplied by the number
of rows in the second table. This is an example of a Transact-SQL cross
join:
Your query joins two tables together but the join does not describe how
those tables are related.
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"news.microsoft.com" <suporte@.hitecnet.com.br> wrote in message
news:ORnEdJ$vDHA.2508@.TK2MSFTNGP12.phx.gbl...
> Hi there,
> I would like to know what is missing in the select instruction below
because
> is repeating 3 times each record. I tried to use
> DDepen CROSS JOIN HT_DBAU001_DCliente and that was worst because brought
me
> much more rows repeated!!!
> Thanks,
> VILMAR
> BRAZIL
> SELECT distinct DDepen.DPCliente, DDepen.DPNome, DDepen.DPEmail,
> DDepen.DPSenha, HT_DBAU001_DCliente.CLSITU
> FROM DDepen,HT_DBAU001_DCliente
> WHERE (DDepen.DPCliente BETWEEN 1 AND 4) AND
(HT_DBAU001_DCliente.CLSITU
> BETWEEN 8 AND 10)
> ORDER BY DDepen.DPCliente, DDepen.DPNome
> Brings me this:
> DPCliente DPNome DPEmail
> DPSenha CLSITU
> -- --- --
--
> -- -- --
--
> --
> 1 José
jr@.XXX.com.br
> 00000 8.0
> 1 José
jr@.XXX.com.br
> 00000 9.0
> 1 José
jr@.XXX.com.br
> 00000 10.0
> 3 Marinho
> lider@.XXX.com.br 00000 8.0
> 3 Marinho
> lider@.XXX.com.br 00000 9.0
> 3 Marinho
> lider@.XXX.com.br 00000 10.0
> (6 row(s) affected)
>
No comments:
Post a Comment