From: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca> |
---|---|
To: | Enrico Mangano <enrico(dot)mangano(at)nethouse(dot)it> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: UPDATE and SELECT result difference |
Date: | 2002-03-14 18:47:12 |
Message-ID: | 3C90F030.8AA01CF@nsd.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello Enrico,
It simply means that there are 202 duplicate rows in acxx_aziende_istat
where acxx_aziende_istat.cda_azienda = temp_principale.cda_azienda.
try :
SELECT cda_azienda, COUNT(*)
FROM acxx_aziende_istat
WHERE EXISTS (
SELECT * FROM temp_principale
WHERE acxx_aziende_istat.cda_azienda = temp_principale.cda_azienda)
GROUP BY cda_azienda
HAVING COUNT(*) > 1;
jll
Enrico Mangano wrote:
>
> Hi all,
>
> of course I'm too drunk, or simply I'm missing something, but
> I can't understand the difference beetwen the results of these
> 2 queries:
>
> targhettariodb=# UPDATE temp_principale
> targhettariodb-# SET cda_istat = acxx_aziende_istat.cda_istat ,
> targhettariodb-# prg_istat = acxx_aziende_istat.prg_istat
> targhettariodb-# WHERE acxx_aziende_istat.cda_azienda =
> temp_principale.cda_azienda;
> UPDATE 1727
> targhettariodb=# SELECT count(*)
> targhettariodb-# FROM acxx_aziende_istat,temp_principale
> targhettariodb-# WHERE acxx_aziende_istat.cda_azienda =
> temp_principale.cda_azienda;
> count
> -------
> 1929
> (1 row)
>
> why this difference in the number of rows?
>
> (
> targhettariodb=# SELECT count(*)
> targhettariodb-# FROM acxx_aziende_istat, temp_principale
> targhettariodb-# WHERE
> targhettariodb-# acxx_aziende_istat.cda_azienda is null OR
> targhettariodb-# temp_principale.cda_azienda is null OR
> targhettariodb-# acxx_aziende_istat.cda_istat IS NULL OR
> targhettariodb-# acxx_aziende_istat.prg_istat IS NULL ;
> count
> -------
> 0
From | Date | Subject | |
---|---|---|---|
Next Message | Vincent Stoessel | 2002-03-14 19:20:19 | temporary file location? |
Previous Message | Jeff Fitzmyers | 2002-03-14 18:22:55 | Re: Random Numbers/Letters |