Subject Re: subselect in update : how to force a plan ?
Author Svein Erling Tysvær
--- In firebird-support@yahoogroups.com, Helen Borrie wrote:
> At 04:17 PM 11/08/2004 -0400, you wrote:
> >Hi,
> >
> >I'm trying to run an update on a table like this :
> >
> >update examen e set e.protocole='C'
> >where e.id_visite in (select id_visite FROM Patient
> >left join Visite on (Patient.ID_Patient = Visite.ID_Patient)
> >WHERE Patient.ID_Patient = '45691')
>
> update examen e
> set e.protocole='C'
> where EXISTS (
> select 1 from Patient p
> join Visite v on p.ID = v.ID_Patient
> WHERE p.ID_Patient = '45691')
>
> /heLen

Hmm, Helen, you forgot one important line here...

update examen e
set e.protocole='C'
where EXISTS (
select 1 from Patient p
join Visite v on p.ID = v.ID_Patient
WHERE p.ID_Patient = '45691'
AND e.id_visite = v.id_visite)

(this is assuming id_visite to belong to visite and not patient)

Martijn had a serious Bamsemums fatigue, but even if you try to
simulate his condition, you're simply to clever in your numerous
replies to this list for me to ever fall for that trick.

Set