Update a table in informix (an entire field)

62 views Asked by At

I know SQL fairly well but I'm now working on informix and I don't think I know SQL at all any more.

I have the orders table called "cde" and the article table called "art" which are linked by the no_art column. I want to update the column "no_lieu" in the cde table with the value of the column "prin_lieu" in the art table.

I have tried many things but I already have the same error : SQL Error [42000]: A syntax error has occurred.

Here are a few examples :

update 
    cde
set 
    no_lieu = (
    select
        art.lieu_prin
    from
        cde
    left join art on
        cde.no_art = art.no_art)
where
    etat_lig in ('1', '0');
update
    cde
set
    cde.no_lieu = art.lieu_prin
from
    art
where
    cde.no_art = art.no_art
    and cde.no_lieu <> art.lieu_prin;
update
    cde
set
    cde.no_lieu = (
    select
        art.lieu_prin
    from
        art
    where
        cde.no_art = art.no_art
);
update 
    cde
set 
    cde.no_lieu = art.lieu_prin
from 
    cde
inner join 
    art on
    cde.no_art = art.no_art
where
    cde.etat_lig in ('1', '0');

Thanks for your help,

1

There are 1 answers

0
halboxx On

this works for me...

set 
   cde.no_lieu = ( select art.lieu_prin from art where cde.no_art = art.no_art ) 
where 
    cde.etat_lig in ('1', '0')
and
  exists (select 'I am groot' from art where cde.no_art = art.no_art ) ;