Can Union (mysql) also be used in Updates?

Asked

Viewed 46 times

0

Example :

$query = "update tabela set coluna1 = 1 where id = {$id_m} union
          update tabela set coluna2 = 1 where id = {$id_v}";

1 answer

1

  • Is there any way I can change data from different columns but leaving it in one query?

  • try: $query = "update table set column1 = 1 Where id = {$id_m}; update table set column2 = 1 Where id = {$id_v}";

  • Returned a syntax error for the second update...

  • here i got $sql = 'update category set name=? Where id=? ; update category set name=? Where id=? '; $bindings = array('abc',1, 'cba',2); $stmt = $Pdo->prepare($sql); $result = $stmt->execute($bindings); echo $result; //true

Browser other questions tagged

You are not signed in. Login or sign up in order to post.