title: Updating selected rows in Firebird
body: <p>I want to modify my query. Right now it looks like this </p>
  
  <pre><code>SELECT EW_POLYLINE.P0_X, EW_POLYLINE.P0_Y, EW_POLYLINE.ID, EW_POLYLINE.STAN_ZMIANY, a.IDE, EW_POLYLINE.ID_WARSTWY
  FROM EW_POLYLINE 
  LEFT JOIN (
      SELECT EW_OBIEKTY.STATUS
          , EW_OB_ELEMENTY.IDE
          , EW_OB_ELEMENTY.TYP
      FROM EW_OBIEKTY 
      INNER JOIN EW_OB_ELEMENTY 
          ON EW_OBIEKTY.UID = EW_OB_ELEMENTY.UIDO
      WHERE EW_OBIEKTY.STATUS = 0 AND EW_OB_ELEMENTY.TYP &lt;&gt; 1
  ) as a ON EW_POLYLINE.ID = a.IDE
  WHERE EW_POLYLINE.STAN_ZMIANY = 0 AND a.IDE Is Null
  </code></pre>
  
  <p>Right now it returns like 1/3 of database, and I want to modify "stan_zmiany" of these rows to 3. Since I can not use UPDATE FROM construction in Firebird I tried </p>
  
  <pre><code>update EW_POLYLINE
  set stan_zmiany = 3
  WHERE EXISTS (SELECT 1
  FROM EW_POLYLINE 
  LEFT JOIN (
      SELECT EW_OBIEKTY.STATUS
          , EW_OB_ELEMENTY.IDE
          , EW_OB_ELEMENTY.TYP
      FROM EW_OBIEKTY 
      INNER JOIN EW_OB_ELEMENTY 
          ON EW_OBIEKTY.UID = EW_OB_ELEMENTY.UIDO
      WHERE EW_OBIEKTY.STATUS = 0 AND EW_OB_ELEMENTY.TYP &lt;&gt; 1
  ) as a ON EW_POLYLINE.ID = a.IDE
  where EW_POLYLINE.STAN_ZMIANY = 0 AND a.IDE Is Null)
  </code></pre>
  
  <p>but it change "stan_zmiany" for all rows, not for selected in first query, do you know how to fix this? </p>