The task is to replace the expiration date of the document (datee) with 2012-12-12 for records with status 500 (status field).

A little wrong form the question. There is a script

select * from polis join pers on polis.idpers=pers.idpers join PersStatus on polis.idpers=PersStatus.idpers where idstatus='52' and polis.polisdateF is null and polis.polistype!=1 and datestatus between '20120101' and '20121107' 

Then in that he chose (list). In this list, all change the date (polisdatee) for where idstatus = '52 '.

 update polis set polisdatee='20121015' where ??? 
  • one
    And what konkternno not work? - user6550
  • Moved to the question. - egoist522
  • How to change data in a completely different table according to the sample - egoist522

2 answers 2

If your request refers to two tables, then in UPDATE it is necessary to register the alias of the table, the data in which you are going to update.

An example of updating a table attached in a join:

 update t2 set somefield = 'somevalue' from table t inner join table2 t2 on = where something = 1 

An example is clear, or need to explain in more detail? If more detailed - please give an example of your query with an explanation of which field is in which table (from the query in the commentary to the question it is not clear).

  • there are tables polis and PersStatus I link them by idpers I select only those that have idstatus = '52 '(idstatus field in table PersStatus). A list is formed. then in this list I need to replace the field polisdatee in the table polis - egoist522
  • Lay out the schema of the tables, so they will help you faster - Donil
  • 1 table Polis fields idpers, polisdatee 2 table PersStatus fields idpers, idstatus You need to select records with idstatus = 52 and then change polisdatee for these records in another table - egoist522

According to the results of comments (if I understood everything correctly), something like this:

 update Polis set polisdatee='20121015' where idpers in (select idpers from PersStatus where idstatus=52)