Subject Re: [firebird-support] Joining table in UPDATE statement?
Author Alexandre Benson Smith
Anthony Tanas wrote:
> I'm trying to do this:
>
> UPDATE
> PATIENTRECALL
> SET
> PATIENTRECALL.RECALLSTATUS = 'rsMail'
> FROM
> PATIENTRECALL
> INNER JOIN PATIENT ON (PATIENTRECALL.PATIENTID = PATIENT.PATIENTID)
> WHERE
> PATIENTRECALL.RECALLDATE >= :STARTDATE AND
> PATIENTRECALL.RECALLDATE <= :ENDDATE AND
> PATIENT.INACTIVEPATIENT = 'F' AND
> PATIENTRECALL.RECALLSTATUS <> 'rsCancelled' AND
> PATIENTRECALL.RECALLSTATUS <> 'rsRecalled'
>
> But it doesn't work...I also tried:
>
> UPDATE
> PATIENTRECALL
> INNER JOIN PATIENT ON (PATIENTRECALL.PATIENTID = PATIENT.PATIENTID)
> SET
> PATIENTRECALL.RECALLSTATUS = 'rsMail'
> WHERE
> PATIENTRECALL.RECALLDATE >= :STARTDATE AND
> PATIENTRECALL.RECALLDATE <= :ENDDATE AND
> PATIENT.INACTIVEPATIENT = 'F' AND
> PATIENTRECALL.RECALLSTATUS <> 'rsCancelled' AND
> PATIENTRECALL.RECALLSTATUS <> 'rsRecalled'
>
> Can someone point me in the right direction? Thanks in advance.
>

Hi Anthony,

Try this:

UPDATE
PATIENTRECALL
SET
PATIENTRECALL.RECALLSTATUS = 'rsMail'
WHERE
PATIENTRECALL.RECALLDATE >= :STARTDATE AND
PATIENTRECALL.RECALLDATE <= :ENDDATE AND
PATIENTRECALL.RECALLSTATUS <> 'rsCancelled' AND
PATIENTRECALL.RECALLSTATUS <> 'rsRecalled' and
exists (select 1 from Patient where PATIENT.INACTIVEPATIENT = 'F' AND PATIENTRECALL.PATIENTID = PATIENT.PATIENTID)


see you !


--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br