How to do a double "Update" in MySQL

1

I'm developing software in PHP / HTML / MYSQL FRONT. I need to give a Update in a table but changing two columns at one time. Here comes my doubt in the variable $ gravaprat1, since it is not executing the second command (SEND = 1). Next:

$selectsql = "select osi, entrada, vendedor, prateleira, now(), abs(DATEDIFF(now(), str_to_date(entrada,'%Y-%m-%d'))) as dias from itens;";
$res = mysqli_query($conn, $selectsql);

$gravaprat1 = "update itens set prateleira = 1 where abs(DATEDIFF(now(), str_to_date(entrada,'%Y-%m-%d'))) < 30 ***(NESSA PARTE ESTOU COM DUVIDA -->)***and update itens set enviar = 1";   
$prat1sql = mysqli_query($conn, $gravaprat1);
    
asked by anonymous 13.07.2018 / 19:07

2 answers

5

Your SQL should look like this:

 update itens 
    set prateleira = 1 
       ,enviar     = 1
  where abs(DATEDIFF(now(), str_to_date(entrada,'%Y-%m-%d'))) < 30

In an UPDATE you must separate the fields by "," (Virgula), and inform them before the WHERE

    
13.07.2018 / 19:13
3

Hello

$selectsql = "select osi, entrada, vendedor, prateleira, now(), abs(DATEDIFF(now(), str_to_date(entrada,'%Y-%m-%d'))) as dias from itens;";
$res = mysqli_query($conn, $selectsql);

$gravaprat1 = "update itens set prateleira = 1, enviar = 1 where abs(DATEDIFF(now(), str_to_date(entrada,'%Y-%m-%d'))) < 30";   
$prat1sql = mysqli_query($conn, $gravaprat1);
    
13.07.2018 / 19:15