Skip to content

Instantly share code, notes, and snippets.

@vidux
Created October 13, 2018 03:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vidux/a5e0318f8457d483d3afd4379d116164 to your computer and use it in GitHub Desktop.
Save vidux/a5e0318f8457d483d3afd4379d116164 to your computer and use it in GitHub Desktop.
Move A row to another same-field talbe php
table:Foo
+------------+
|id|name|age |
+------------+
|2|Vidx| 24 |
+------------+
table:bar
+------------+
|id|name|age |
+------------+
<?php
$sql="INSERT INTO bar SELECT * FROM Foo WHERE id = '2'";
if (mysqli_query($conn, $sql)) {
mysqli_query($conn, "DELETE FROM Foo WHERE id = '2'");
} else {
echo "error";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment