Guest User

Untitled

a guest
Nov 17th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. +---------+---------+----------+
  2. | TABELA2 | TABELA1 | |
  3. +---------+---------+----------+
  4. | cod1 | cod1 | |
  5. +---------+---------+----------+
  6. | | cod2 | EXCLUIDO |
  7. +---------+---------+----------+
  8. | cod3 | cod3 | |
  9. +---------+---------+----------+
  10. | | cod4 | EXCLUIDO |
  11. +---------+---------+----------+
  12.  
  13. $teste1 = "SELECT * FROM tabela2 as a INNER JOIN tabela1 as c ON (a.cod2=c.cod1)";
  14. $teste2 = mysqli_query ($db,$teste1);
  15. while($teste3 = mysqli_fetch_array($teste2)){
  16. $teste = $teste3["0"];
  17.  
  18. $insert = "UPDATE tabela1 SET campo = 'Entregue' WHERE cod1 NOT IN ($teste)";
  19. mysqli_query ($db,$insert);
  20. }
  21.  
  22. select * from tabela1 t1 where not exists(select * from tabela2 t2 where t2.id = t1.id )
  23.  
  24. update tabela1 t1 set t1.status = "EXCLUIDO" where not exists(select * from tabela2 t2 where t2.id = t1.id )
Add Comment
Please, Sign In to add comment