Jump to content

Move selected fields from one mysql table to another


thomo03

Recommended Posts

Hi guys...I'm having trouble!!

 

I can manage to move ALL my table data from one table to another, however I want to move only SELECT data, for stats, and delete the other data which is sensitive.

 

I have included a picture of the table set-up.

 

I have also sorted out a seperate include file for the database connection, so that isn't an issue, it just seems to be my code.

 

When I execute the file, my error is returned as nvalid query: Operand should contain 1 column(s)

 

The current PHP I have is

 

<?php
if(!isset($_POST['id']))
    header("Location: ".$_SERVER['HTTP_REFERER']); 
require_once('config.inc.php');
require_once('common.inc.php');
require_once('connection.inc.php');
$ids        = implode(',',$_POST['id']);
$queryInsert= "INSERT INTO $dest_table (id, date) (SELECT (id, date) FROM $src_table WHERE id IN ($ids))";
$queryDelete= "DELETE FROM $src_table WHERE id IN ($ids)";
if(!mysql_query($queryInsert))
die('Invalid query: ' . mysql_error());
if(!mysql_query($queryDelete))
die('Invalid query: ' . mysql_error());
header("Location: ".$_SERVER['HTTP_REFERER']);  
?>

 

 

Please help guys.

 

Thank you in advance

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.