S4b0r

导航

mysql 查询去除空格字符然后倒入新表

/*

导入数据的时候,有空白字符,去除一下然后导出。

四年前干的事,现在再干一遍。

*/

$dbhost= '127.0.0.1';
$dbuser= 'root';
$dbpass= '123456789';
$db= '123456';

$conn = @mysql_connect($dbhost,$dbuser,$dbpass);

$db = mysql_select_db($db,$conn);

$table = mysql_query("select * from user limit 50001,80000");

$insert = array();
	while ($tables = mysql_fetch_array($table)){

		$insert['id'] = $tables['id'];
		$insert['username'] = trim($tables['username']);
		$insert['password'] = trim($tables['password']);
		$insert['kk'] = $tables['kk'];
		mysql_query("INSERT INTO `user1` VALUES ('".$insert['id']."',
		'".$insert['username']."',
		'".$insert['password']."',
		'".$insert['kk']."')")."<br>";
	}

  

posted on 2015-11-12 22:41  S4b0r  阅读(665)  评论(0编辑  收藏  举报