Subject | Problem with LEFT OUTER JOIN and COUNT() |
---|---|
Author | Fabio Gomes |
Post date | 2006-04-10T13:25:28Z |
Hi guys,
I have a pagination function in php that uses a counter to generate the page
links and stuff, it always worked fine, but i m having a problem with this
query:
I m using this to count the results:
SELECT DISTINCT COUNT(*)
FROM SIAD_VND N
LEFT OUTER JOIN SIAD_VED V ON (V.CODIGO = N.VEDEXT)
WHERE TIPO='V' AND N.OBS3 LIKE '%SUS%'
And this to show them:
SELECT DISTINCT N.EMISSAO, N.CUPOM, N.OBS1, N.OBS3, V.DESCRICAO
FROM SIAD_VND N
LEFT OUTER JOIN SIAD_VED V ON (V.CODIGO = N.VEDEXT)
WHERE TIPO='V' AND N.OBS3 LIKE '%SUS%'
But the problem is that the COUNT() returns me 2000+ rows, and the query
return just 1000, i tried to change the query and stuff. but it isnt
working, i think that it have something to do with the LEFT OUTER JOIN.
Am i doing something wrong?
Anyway, any help is welcome.
Thanx,
-Fábio.
[Non-text portions of this message have been removed]
I have a pagination function in php that uses a counter to generate the page
links and stuff, it always worked fine, but i m having a problem with this
query:
I m using this to count the results:
SELECT DISTINCT COUNT(*)
FROM SIAD_VND N
LEFT OUTER JOIN SIAD_VED V ON (V.CODIGO = N.VEDEXT)
WHERE TIPO='V' AND N.OBS3 LIKE '%SUS%'
And this to show them:
SELECT DISTINCT N.EMISSAO, N.CUPOM, N.OBS1, N.OBS3, V.DESCRICAO
FROM SIAD_VND N
LEFT OUTER JOIN SIAD_VED V ON (V.CODIGO = N.VEDEXT)
WHERE TIPO='V' AND N.OBS3 LIKE '%SUS%'
But the problem is that the COUNT() returns me 2000+ rows, and the query
return just 1000, i tried to change the query and stuff. but it isnt
working, i think that it have something to do with the LEFT OUTER JOIN.
Am i doing something wrong?
Anyway, any help is welcome.
Thanx,
-Fábio.
[Non-text portions of this message have been removed]